Coder Social home page Coder Social logo

slim-views's People

Contributors

itsgoingd avatar kachar avatar silentworks avatar tassoevan avatar thijsw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slim-views's Issues

How to set the TwigEnviroment ?

Hi

I need to set the TwigEnviroment (or better the TraceableTwigEnvironment) in Slim.
I'm trying to integrate your project with the DebugBar project.

Any advice ?

Regards

Andrea

Support for Twig extensions?

Maybe I'm missing something, but I don't see a way in the docs to do $twig->addExtension()

After upgrading a project to slim-views from extras, I'm not able to use Twig's dump function because of this

Is this functionality in the pipeline, or is it already there and I just need more coffee?

Fatal Error: Class Twig_Extension not found

When try to load Twig Extension as indicated in the manual, I get this error
Fatal error: Class 'Twig_Extension' not found.

I think it is the Parent class of TwigExtension that is the problem.

urlFor, baseUrl, siteUrl functions in twig do not exist.

Type: Twig_Error_Syntax
Message: The function "urlFor" does not exist in "views/base.html.twig" at line 28

this is what i get when i try to use all thre functions.

my composer.json:

{
    "require" : {
        "slim/slim" : "2.*",
        "doctrine/orm" : "2.4.*@dev",
        "slim/views" : "0.1.*",
        "twig/twig" : "1.*"
    }
}

templates.path

Setting templates.path in the Slim configuration options doesn't set the path for the Twig view. This creates exceptions like:
Uncaught exception 'Twig_Error_Loader' with message 'The "" directory does not exist.

It should at least be documented that $view->setTemplatesDirectory(PATH_TO_DIRECTORY) needs to be called for this to work

Multiple template dirs

Is it not possible to have multiple template directories?

$view->setTemplatesDirectory($dir);

seems to only accept one directory, as does the config. The $twigTemplateDirs will be deprecated it says, so I am not using that :)

Redirect not working

Hi.
I have a problem.
Why does not it work redirect?

$app = new \Slim\App();
$app->get('/', function ($request, $response, $args) {
return $response->withRedirect($this->router->pathFor('name'));//not work
});

$app->get('/auth/signup', function ($request, $response, $args) {
return 'Hello';
})->setName('name');

$app -> run();

or


$app->get('/', function ($req, $res, $args) {
  return $res->withStatus(302)->withHeader('Location', '/auth/signup'); //Not work
});

Thanks!,

Strict standards error

I'm getting the following exception:

Strict Standards: Declaration of Slim\Views\Twig::render() should be compatible with that of Slim\View::render()

I cleared it up by adding $data=null as a parameter to Slim\Views\Twig::render() even though the extra argument doesn't seem to be useful.

Update to support new twig auto loading

the new version you get with composer require twig/twig changes he way autoloader works and deletes some classes so this slim views don't work any more with it.

Class 'Twig_Extension' not found

Hello,

I've a problem with Twig Extension :

    require 'vendor/autoload.php';

    $app = new \Slim\Slim(array(
        'debug' => true,
        'templates.path' => 'views/',
        'view' => new \Slim\Views\Twig(),
    ));

    $view = $app->view();
    $view->parserOptions = array(
        'debug' => true,
    );
    $view->parserExtensions = array(
        new \Slim\Views\TwigExtension()
    );




    $app->get('/hello/:name', function ($name) use ($app) {
        $app->render('hello.html.twig', array(
            'name' => $name,
        ));
    });

    $app->run();

And the error : Fatal error: Class 'Twig_Extension' not found in ***\vendor\slim\views\TwigExtension.php on line 38

Have you any ideas ?

Thanks

Add support for multiple templates dirs

Can you add support for setting multiple templares dirs? Twig already support it, why don't add it to this lib?

Simply edit in Slim\Views\Twig:

/**
 * DEPRECATION WARNING! This method will be removed in the next major point release
 *
 * Get a list of template directories
 *
 * Returns an array of templates defined by self::$twigTemplateDirs, falls
 * back to Slim\View's built-in getTemplatesDirectory method.
 *
 * @return array
 **/
private function getTemplateDirs()
{
    if (empty($this->twigTemplateDirs)) {
        return $this->getTemplatesDirectory();
    }
    return $this->twigTemplateDirs;
}

/**
 * Sets an array of paths where to look for templates.
 * @param  string|array $directory
 */
public function setTemplatesDirectory($directory)
{
    $this->templatesDirectory = $directory;
}

Differences between baseUrl() and currentUrl()

What's the difference between baseUrl() and currentUrl() ?
If I'm on the page http://www.iubar.it/index.php, how can I get the address http://www.iubar.it (wihout the page name) ???
Thank you in advance for any help

Regards

Andrea

Only for technical curiosity. It's not an issue

Hello

I use your code with the Twig view.
When I write:

$this->app->render();
$this->app->log->debug('Writing a log message after page rendering.');

I could read the log message in the debug bar, while if I don't use your code, but the raw DebugBar code, the message is never showed.

Why ?

Thank you in advance

Andrea

Support multiple view types

My apologies if this is already a feature .. I couldn't find it documented anywhere.

It'd be really handy if Slim could support multiple view types in the same application. My particular use case is:
I want user-facing views to be rendered as Twig templates, since it makes sense to use a specialised HTML-rendering template engine for that. However, I also generate files from data passed to the system (in my case a particular type of tab-delimited file), but could equally be CSV, XLS, PDF, ... whatever

I can do this by simply spitting out stuff that I want, but it'd be really nice to be able to have a 'view' so that the template file in question could be edited by people who are experts in genomics, but perhaps not in web development

Thanks ๐Ÿ‘

current Slim-Views master requires a too low Slim-Version in composer.json

Slim-Views calls "$this->all()" method in Twig.php:88, which is not provided in Slim only since 2.3.0

git diff:
diff --git a/composer.json b/composer.json
index ad88722..14b8286 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,7 @@
}
],
"require": {

  •    "slim/slim": ">=2.2.0",
    
  •    "slim/slim": ">=2.3.0",
     "php": ">=5.3.0"
    
    },
    "autoload": {

how to use {{ dump(var) }} with twig?

how to use {{ dump(var) }} with twig? since the last update v1.1.0 Twig extension, Debug is become impaired, what to do? :(

twigphp/Twig-extensions@c0ab818

index.php (Bootstrap)

<?php
define('ROOT', dirname(__DIR__));

# Autoload
$loader = require ROOT.'/vendor/autoload.php';
// $loader->add('Lib', ROOT.'/lib/');
// spl_autoload_register(function($class){
//  $list = [
//      ROOT.'/app/'.$class.'.php',
//      ROOT.'/lib/'.$class.'.php',
//      ROOT.'/lib/'.$class.'.class.php',
//  ];
//  foreach($list as $k => $v){if(file_exists($v)){
//      include $v; return true;
//  }}
// });


# Init Slim
$app = new \SlimController\Slim([
    'mode'                       => 'production',
    'debug'                      => false,
    'view'                       => new \Slim\Views\Twig(),
    'templates.path'             => ROOT.'/templates',
    'cacheDirectory'             => ROOT.'/cache',
    'controller.class_prefix'    => '\\MyApp\\Controller',
    'controller.method_suffix'   => 'Action',
    'controller.template_suffix' => 'html.twig'
]);


# Gestion de la configuration selon le mode
if(\Lib\Func::env() == 'LOCAL') $app->config('mode', 'development');

$app->configureMode('production', function() use ($app){
    $app->view->parserOptions    = ['cache' => $app->config('cacheDirectory')];
    $app->view->parserExtensions = [
        new \Slim\Views\TwigExtension()
    ];
});
$app->configureMode('development', function() use ($app){
    $app->config([
        'debug' => true
    ]);
    $app->view->parserOptions    = ['debug' => true];
    $app->view->parserExtensions = [
        new \Slim\Views\TwigExtension(),
        new \Twig_Extensions_Extension_Debug()
    ];
});

# Components

$app->addRoutes([
    '/'            => 'Home:index',
]);

// require_once ROOT.'/app/routes.php';

$app->run();

Twig dump function

Hi I'm trying to use the dump function in a twig template but I get a "The function "dump" does not exist" error. I have the following parser options:

'charset' => 'utf-8',
'auto_reload' => true,
'strict_variables' => false,
'autoescape' => true,
'debug'=>true

Any suggestions would be greatfully recieved.

Other templating

I'm a little confused. If I want to use Mustache, would you accept a pull request to this repo or should I use the deprecated repo or am I supposed to use this, fork, write my own and not contribute back?

I saw that you wanted it to be smaller, but wasn't clear if others wanted to use a different templating engine.

Thanks again!!

Smart Templating Issue

Hi,

I'm trying to get started with Slim Views and Smarty.

I have downloaded Smarty 3.1.x and extracted the libs dir to /var/www/my_site/vendor/smarty.

I have following initialization in my index.php for slim:

<?php

require 'vendor/autoload.php';

require 'app-config.php';

require 'hrcapi-util.php';

$app = new \Slim\Slim(array(
                        'log.writer' => new \Slim\Extras\Log\DateTimeFileWriter(),
                        'view' => new \Slim\Views\Smarty()
                        ));

$view = $app->view();
$view->parserDirectory = '/var/www/my_site/vendor/smarty';
$view->parserCompileDirectory = dirname(__FILE__) . '/compiled';
$view->parserCacheDirectory = dirname(__FILE__) . '/cache';
$view->parserTemplatesDirectory =  dirname(__FILE__) . 'templates';
$view->parserExtensions = array(
    dirname(__FILE__) . '/vendor/slim/views/Slim/Views/SmartyPlugins',
);

When I invoke a route, with a template call as so;

$app->get('/api/members/unsubscribe/:memberid', function ($memberid) use ($app) {
                $app->render('unsubscribe.tpl', array('result' => 'OK'));
                });

I get a blank page and an error in my web server log:

[Wed Aug 28 13:45:07 2013] [error] [client 127.0.0.1] PHP Fatal error:  Call to undefined method Slim\\Views\\Smarty::all() in /var/www/my_site/vendor/slim/views/Slim/Views/Smarty.php on line 87

Any ideas?

Virtual packages and "provide" Composer feature

What about require in composer.json something like slim/slim-views-implementation and make specific packages for each template system (including Plates, as suggested in a PR) matching this requirement viaprovidefeature of Composer? Exactly likepsr/log-implementation` works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.