Giter Site home page Giter Site logo

zetwig's Introduction

ZeTwig

ZeTwig is a Twig / Zend Framework 2 module compatible with ViewModels from beta3. It allows to render view templates using Twig instead of the default PHP templates. It also supports aliases for your template names, rendering a particular action from within the template files (follows the save naming conventions as Symfony) and triggering events on an object with different parameters.

Documentation

Upgraded to the new beta3 version of ZF2 View Models.

Any command from the original Twig library should work and also added support for Zend View helpers as functions and PHP functions as a fallback.

With this new update you should be able to use template names as aliases that can be mapped to any twig file.

You can define an array for aliases within the configuration file for your modules and use those aliases throughout your code, instead of a specific file name. This way you can easily change the main layout of your pages from the configuration file and allow other modules to change them as well (this allows your code to be extensible and allows templates to have their own structure).

This latest version also contains two new constructs:

  1. A tag for rendering a controller action, which follows the Symfony naming conventions or the controller alias and can be used as :

    {% render "Core:Index:index" with {'param1':1} %}

  2. A tag for triggering an event on the renderer that is similar to the above syntax:

    {% trigger "myRendererEvent" on myObject with {'param1':1} %}

    Both the target object and parameters are optional. The result of each listener is converted to string and rendered intead of the definition.

Also a new functionality allows the use of aliases within your template code or when rendering a template.

zetwig's People

Contributors

cosmin-harangus avatar

Stargazers

 avatar

Watchers

 avatar

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.