2017 © Pedro Peláez
 

library smartwig

Ultimate Components Extension for Twig.

image

yepsua/smartwig

Ultimate Components Extension for Twig.

  • Thursday, March 23, 2017
  • by oyepez003
  • Repository
  • 1 Watchers
  • 5 Stars
  • 2,198 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

SmarTwig

Ultimate Components Extension for Twig., (*1)

You can use Twig and SmarTwig and any PHP Project., (*2)

Installation

You can install the SmarTwig in 2 different ways:, (*3)

  1. Use the Git repository
  2. Install it via Composer on Packagist

The Assets:

All the SmarTwig Components need some .css and .js files to work., (*4)

Get the resources cloning the Git repository or [ Download the Zip] (https://github.com/oyepez003/jquery4php-assets/archive/master.zip), (*5)

Put content of the repo in your app public folder., (*6)

How To Use (3 Ways)

1) The Ugly Way:

Load all Extensions and the Builders Configuration step by step., (*7)

``` php require_once 'vendor/autoload.php';, (*8)

$loader = new Twig_Loader_Filesystem('templates'); $twig = new Twig_Environment($loader, array( 'cache' => 'cache', 'debug' => true // Only for dev enviroment. ));, (*9)

$coreExt = new Yepsua\SmarTwig\Twig\Extension\UICoreExtension(); $coreExt->setBuilders(array( "ui.html" => "YsHTML", "ui.jqueryCore" => "YsJQuery", "ui.dialog" => "YsUIDialog", "ui.tabs" => "YsUITabs", "ui.accordion" => "YsUIAccordion", "ui.progressbar" => "YsUIProgressbar", "ui.slider" => "YsUISlider", "ui.autocomplete" => "YsUIAutocomplete", "ui.datepicker" => "YsUIDatepicker", "ui.datetimepicker" => "YsUIDateTimepicker", "ui.button" => "YsUIButton", "ui.multiselect" => "YsUIMultiSelect", "ui.picklist" => "YsUIPickList", "ui.popup" => "YsUIPopUp", "ui.selectmenu" => "YsUISelectMenu", "ui.expander" => "YsUIExpander", "ui.splitter" => "YsUISplitter", "ui.dynaselect" => "YsUIDynamicSelect", "ui.menu" => "YsUIMenu", "ui.panel" => "YsUIPanel", "ui.tooltip" => "YsUITooltip", "ui.draggable" => "YsUIDraggable", "ui.droppable" => "YsUIDroppable", "ui.resizable" => "YsUIResizable", "ui.effect" => "YsUIEffect", "ui.video" => "YsUIVideo" ));, (*10)

$uiAddonsExt = new Yepsua\SmarTwig\Twig\Extension\UIAddonsExtension(); $uiAddonsExt->setBuilders(array( "ui.block" => "YsBlockUI", "ui.box" => "YsJQBox", "ui.colorpicker" => "YsJQColorPicker", "ui.notify" => "YsPNotify", "ui.hotkey" => "YsKeys", "ui.monitor" => "YsJQMonitor", "ui.keypad" => "YsJQKeypad", "ui.calculator" => "YsJQCalculator", "ui.layout" => "YsJLayout", "ui.mask" => "YsJQMask", "ui.formWizard" => "YsFormWizard", "ui.ajaxForm" => "YsJQForm", "ui.validation" => "YsJQValidate", "ui.booklet" => "YsJQBooklet", "ui.cycle" => "YsJQCycle", "ui.ring" => "YsJQRing", "ui.upload" => "YsUpload", ));, (*11)

//Set all extension to Twig, (*12)

$twig->setExtensions(array( new Yepsua\SmarTwig\Twig\Extension\HTMLExtension(), new Yepsua\SmarTwig\Twig\Extension\JsSintaxExtension(), new Yepsua\SmarTwig\Twig\Extension\JQueryCoreExtension(), new Yepsua\SmarTwig\Twig\Extension\UIWidgetExtension(), $coreExt, $uiAddonsExt ));, (*13)


2) The Short Way: ----------------- Load all Extensions and the Builders Configuration in one line of code. ``` php require_once 'vendor/autoload.php'; $loader = new Twig_Loader_Filesystem('templates'); $twig = new Twig_Environment($loader, array( 'cache' => 'cache', 'debug' => true // Only for dev enviroment. )); $twig->setExtensions( Yepsua\SmarTwig\Twig\Extension\SmarTwigExtension::getAllExtensions() );

3) The Pretty Way:

Load all Extensions and the Builders Configuration using The IoC Symfony Component., (*14)

You need add to your composer.json the next dependencies:, (*15)

``` yml "require": { "symfony/dependency-injection": "2.3.@dev", "symfony/config": "2.4.@dev", "yepsua/smartwig": "1.0.*" }, (*16)


``` php require_once 'vendor/autoload.php'; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; $container = new ContainerBuilder(); $loader = new XmlFileLoader($container, new FileLocator(__DIR__)); $loader->load('path/to/services.xml'); $twig = $container->get('twig');

Now you can write all the services configuration in the service.xml file:, (*17)

``` xml , (*18)

, (*19)

YsHTML YsJQuery YsHTML YsUIDialog YsUITabs YsUIAccordion YsUIProgressbar YsUISlider YsUIAutocomplete YsUIDatepicker YsUIDateTimepicker YsUIButton YsUIMultiSelect YsUIPickList YsUIPopUp YsUISelectMenu YsUIExpander YsUISplitter YsUIDynamicSelect YsUIMenu YsUIPanel YsUITooltip YsUIDraggable YsUIDroppable YsUIResizable YsUIEffect YsBlockUI YsJQBox YsJQColorPicker YsPNotify YsKeys YsJQMonitor YsJQKeypad YsJQCalculator YsJLayout YsJQMask YsFormWizard YsJQForm YsJQValidate YsJQBooklet YsJQCycle YsJQRing YsUIVideo YsUpload templates cache true %twig.loader.filesystem.location% %twig.config.cache% %twig.config.debug% , (*20)

<!-- TWIG EXTENSIONS -->
<service id="smartwig.ui.core" class="Yepsua\SmarTwig\Twig\Extension\UICoreExtension">
  <tag name="twig.extension" alias="ui.core" />
  <call method="setBuilders">
    <argument type="collection">
      <argument key="ui.html">%html.builder.class%</argument>
      <argument key="ui.jqueryCore">%jquery.core.builder.class%</argument>
      <argument key="ui.dialog">%jquery.ui.dialog.class%</argument>
      <argument key="ui.tabs">%jquery.ui.tabs.class%</argument>
      <argument key="ui.accordion">%jquery.ui.accordion.class%</argument>
      <argument key="ui.progressbar">%jquery.ui.progressbar.class%</argument>
      <argument key="ui.slider">%jquery.ui.slider.class%</argument>
      <argument key="ui.autocomplete">%jquery.ui.autocomplete.class%</argument>
      <argument key="ui.datepicker">%jquery.ui.datepicker.class%</argument>
      <argument key="ui.datetimepicker">%jquery.ui.datetimepicker.class%</argument>
      <argument key="ui.button">%jquery.ui.button.class%</argument>
      <argument key="ui.multiselect">%jquery.ui.multiselect.class%</argument>
      <argument key="ui.picklist">%jquery.ui.picklist.class%</argument>
      <argument key="ui.popup">%jquery.ui.popup.class%</argument>
      <argument key="ui.selectmenu">%jquery.ui.selectmenu.class%</argument>
      <argument key="ui.expander">%jquery.ui.expander.class%</argument>
      <argument key="ui.splitter">%jquery.ui.splitter.class%</argument>
      <argument key="ui.dynaselect">%jquery.ui.dynaselect.class%</argument>
      <argument key="ui.menu">%jquery.ui.menu.class%</argument>
      <argument key="ui.panel">%jquery.ui.panel.class%</argument>
      <argument key="ui.tooltip">%jquery.ui.tooltip.class%</argument>
      <argument key="ui.draggable">%jquery.ui.draggable.class%</argument>
      <argument key="ui.droppable">%jquery.ui.droppable.class%</argument>
      <argument key="ui.resizable">%jquery.ui.resizable.class%</argument>
      <argument key="ui.effect">%jquery.ui.effect.class%</argument>
      <argument key="ui.video">%jquery.ui.video.class%</argument>
    </argument>   
  </call>      
</service>
<service id="smartwig.ui.addons" class="Yepsua\SmarTwig\Twig\Extension\UIAddonsExtension">
  <tag name="twig.extension" alias="ui.addons" />
  <call method="setBuilders">
    <argument type="collection">
      <argument key="ui.block">%jquery.ui.blockui.class%</argument>
      <argument key="ui.box">%jquery.ui.box.class%</argument>
      <argument key="ui.colorpicker">%jquery.ui.colorpicker.class%</argument>
      <argument key="ui.notify">%jquery.ui.notify.class%</argument>
      <argument key="ui.hotkey">%jquery.ui.keys.class%</argument>
      <argument key="ui.monitor">%jquery.ui.monitor.class%</argument>
      <argument key="ui.keypad">%jquery.ui.keypad.class%</argument>
      <argument key="ui.calculator">%jquery.ui.calculator.class%</argument>
      <argument key="ui.layout">%jquery.ui.layout.class%</argument>
      <argument key="ui.mask">%jquery.ui.mask.class%</argument>
      <argument key="ui.formWizard">%jquery.ui.formWizard.class%</argument>
      <argument key="ui.ajaxForm">%jquery.ui.ajaxForm.class%</argument>
      <argument key="ui.validation">%jquery.ui.validation.class%</argument>
      <argument key="ui.booklet">%jquery.ui.booklet.class%</argument>
      <argument key="ui.cycle">%jquery.ui.cycle.class%</argument>
      <argument key="ui.ring">%jquery.ui.ring.class%</argument>
      <argument key="ui.upload">%jquery.ui.upload.class%</argument>
    </argument>   
  </call>      
</service>
<service id="smartwig.sintax" class="Yepsua\SmarTwig\Twig\Extension\JsSintaxExtension">
  <tag name="twig.extension" alias="js.sintax" />
</service>
<service id="smartwig.jquery.core" class="Yepsua\SmarTwig\Twig\Extension\JQueryCoreExtension">
  <tag name="twig.extension" alias="jquery.core" />
</service>
<service id="smartwig.html.tags" class="Yepsua\SmarTwig\Twig\Extension\HTMLExtension">
  <tag name="twig.extension" alias="html.tags" />
</service>  
<!-- TWIG EXTENSIONS -->

, (*21)


This way is the most recommended for performance and scalability. Basic Usage =========== The /index.php content: ``` php require_once 'vendor/autoload.php'; $loader = new Twig_Loader_Filesystem('templates'); $twig = new Twig_Environment($loader, array( 'cache' => 'cache', 'debug' => true // Only for dev enviroment. )); $twig->setExtensions( Yepsua\SmarTwig\Twig\Extension\SmarTwigExtension::getAllExtensions() ); echo $twig->render('index.html', array('name' => 'Fabien'));

The /templates/index.html content:, (*22)

``` html , (*23)

{% include 'path/to/jquery4php-assets/smartwigAssets.html' %}, (*24)

, (*25)

{% ui_dialog title="Hello World" %} The name is: {{ name }} {% end_ui_dialog %}

```, (*26)

Info:

The smartwigAssets.html is an example file for test all the SmarTwig Components, You must edit this file for include only that you need., (*27)

SmarTwig Showcase, (*28)

The Sf2 Bundle

If you are using Sf2 Framework we recommend the SmarTwigBundle, (*29)

Enjoy, (*30)

Showcase Twig jQuery4PHP, (*31)

The Versions

23/03 2017

dev-master

9999999-dev http://smartwig.yepsua.com

Ultimate Components Extension for Twig.

  Sources   Download

MIT

The Requires

 

18/03 2015

1.2.x-dev

1.2.9999999.9999999-dev http://smartwig.yepsua.com

Ultimate Components Extension for Twig.

  Sources   Download

MIT

The Requires

 

17/03 2015

1.1.x-dev

1.1.9999999.9999999-dev http://smartwig.yepsua.com

Ultimate Components Extension for Twig.

  Sources   Download

MIT

The Requires

 

17/03 2015

v1.1.0

1.1.0.0 http://smartwig.yepsua.com

Ultimate Components Extension for Twig.

  Sources   Download

MIT

The Requires

 

15/01 2014

v1.0.0

1.0.0.0

Ultimate Components Extension for Twig.

  Sources   Download

MIT

The Requires