2017 © Pedro Peláez
 

library rhubarb-module-leaf-twigview

Twig integrated View for Rhubarb

image

smcgarrity/rhubarb-module-leaf-twigview

Twig integrated View for Rhubarb

  • Monday, March 12, 2018
  • by smcgarrity
  • Repository
  • 0 Watchers
  • 0 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 433 % Grown

The README.md

Module.Leaf.TwigView

Integration of Twig HTML template engine in a Rhubarb View., (*1)

Creating a Twig View

To create a twig view simply create a View that extends the TwigView class., (*2)

class ProductDetailsView extends TwigView

You will be have to implement two methods:, (*3)

getTwigFileLocation() should return the location of your .twig or .html file as a string., (*4)

function getTwigFileLocation(): string
{
    return __DIR__ . '/File.twig';
}

getTwigVariables() returns an array of values you want to be available in your Twig Template., (*5)

function getTwigVariables() {
    return [
        'PageTitle' => 'Edit Page', 
        'Type' => $this->model->restModel->Type,
        'NameInput' => $this->leaves['NameTextbox'],
    ];
}

You will also need an actual Twig File to be compiled. Twig can compile any HTML file, but has additional support for twig features such as controls and variables. To format twig inputs use the PHPStorm .twig file., (*6)

TwigView uses the printViewContent method to render the HTML so if you extend printViewContent ensure to include a parent call., (*7)

Using Twig

Twig uses brackets { } to insert variables and controls into a HTML template., (*8)

A variable can be output directly using double brackets., (*9)

<p>{{ date }}</p> 

Objects can be access with dot notation in the same way:, (*10)

<p>Dear {{ recipient.Name }},</p> 

Controls can be added using {% %}., (*11)

{% for purchase in purchases  %} 
    {% if purchase.cancelled %} 
        <p class="red">You cancelled your purchase of a {{purchase.product}} on {{purchase.date}} 
    {% else %} 
        <p> you purchased a {{purchase.product}} on {{purchase.date}} for {{purchase.price}}</p> 
    {% endif %} 
{% endfor %} 

Full Twig Documentation: https://twig.symfony.com/doc/2.x/, (*12)

The Versions

12/03 2018

dev-master

9999999-dev https://github.com/smcgarrity/Module.Leaf.TwigView

Twig integrated View for Rhubarb

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework twig php presenter mvp leaf rhubarb

12/03 2018

1.0.0

1.0.0.0 https://github.com/smcgarrity/Module.Leaf.TwigView

Twig integrated View for Rhubarb

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

framework twig php presenter mvp leaf rhubarb