Giter VIP home page Giter VIP logo

neniphptalbundle's Introduction

NeniPhptalBundle

Renderer TAL in Symfony2 with PHPTAL.

INSTALLATION

1. Install via composer

    $ composer require neni/phptal-bundle

As there are no tags yet, you probably want to require the "*@dev" version. The neni/phptal-bundle itself has a *@dev dependency on phptal - this may conflict with the minimum stability settings of your project. If so, you probably want to

    $ composer require phptal/phptal

with the "*@dev" version manually to resolve this conflict.

2. Add bundle to application kernel

Add in file "app/AppKernel.php":

    public function registerBundles()
    {
        return array(
            // ...
            new Neni\PhptalBundle\NeniPhptalBundle(),
            // ...
        );
    }
    // ...
    $loader->registerPrefixes(array(
        // ...
        'PHPTAL'           => __DIR__.'/../vendor/Phptal-svn/classes',
       // ...
    ));

change in the configuration file ("app/config/config.yml")

   framework:
         # ...
         templating: { engines: ['tal', 'twig', 'php'] }
         #...


   # Options 
   neni_phptal: ~ 
         #charset:        "%kernel.charset%"           # encodage
         #output_mode: 	"XHTML"                      # XHTML, XML or HTML5
         #cache_dir: 		"%kernel.cache_dir%/phptal"  # cache location
         #cache_lifetime: 30                           # cache life time in days
         #force_reparse:  false                        # force reparse (for debugging pre_filter)
         #annotation: true
         #pre_filters:
         #   replace_text:
         #        class: "Neni\\PhptalBundle\\Phptal\\Filter\\ReplaceString"
         #        params: ["grenouille", "sauterelle"]
         #   replace_another_text:
         #        class: "Neni\\PhptalBundle\\Phptal\\Filter\\ReplaceString"
         #        params: ["bleue", "rouge"]
         #   remove_comment: 
         #        class: "Neni\\PhptalBundle\\Phptal\\Filter\\RemoveComments"
         #post_filters:
         #    replace_text:
         #        class: "Neni\\PhptalBundle\\Phptal\\Filter\\ReplaceString"
         #        params: ["sauterelle", "souris"]

USAGE

the template extension is '.tal' and you can call it in controllers like this

return $this->render('HelloBundle:Hello:index.html.tal', array('name' => $name));

the default options can be change in controlers via parameters['_engine_']

public function indexAction()
{
    $engine = array();
    $engine['resolver'] = 'tal.resolver.orm';
    $engine['output_format'] = 'XML';
    return $this->render('NeniSiteBundle:test:index.xml.tal', array('test'=>'un test','_engine_'=>$engine) );
}

if you use Sensio's FrameworkExtraBundle for annotation, use '@extra:Tal' in palce of '@extra:Template'
(do not forget to add "annotation: true" to section neni_phptal in config file)

for helpers, use syntax php:Helper.get('helper_name').methode_name('parameters')

<img tal:attributes="src php:Helper.get('assets').getUrl('bundles/test/img/logo.png')" src="../../public/img/logo.png" alt="logo" />

for render another template (tal, twig or php)

<tal:block tal:content="structure php:Helper.render('FOSUserBundle:User:new_content.html.twig')" />

TODO

  • verify annotation
  • verify filters
  • add prefilter for simplify usage of hepers
  • make tests suite
  • improve documentation

neniphptalbundle's People

Contributors

bingochen87 avatar maltewunsch avatar neni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

neniphptalbundle's Issues

Install through Packagist

I would be nice to have this bundle be available through Packagist.
This would also make it possible to add PHPTAL as a dependency and have Composer install that too.

PHPTAL is already available through Composer/Packagist.


There doesn't seem to be much activity on this bundle for the last 2 years, if you do not have the time/inclination to put any work into this ticket I'd be willing to send you a pull request, once my schedule allows it.

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.