twig, что за

Download Twig, что за

If you can't read please download the document

Upload: alex-demchenko

Post on 20-Jun-2015

1.678 views

Category:

Business


1 download

DESCRIPTION

twig tempalte en

TRANSCRIPT

2. Twig, ...??, 29 11. 3. Twig, ...?template engine &templating language, 29 11. 4. Twig, ...? symfony 2templating layer, 29 11. 5. Twig, ...?template engine twig phpsmarty, 29 11. 6. Twig, ...?/** * This engine knows how to render Twig templates. * * @author Fabien Potencier */class TwigEngine implements EngineInterfacehttps://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/TwigBundle/TwigEngine.php#L20, 29 11. 7. Twig, ...?templating languagetwigphpsmarty, 29 11. 8. Twig, ...? ?, 29 11. 9. Twig, ...?# app/config/config.ymlframework:# ...templating: { engines: [twig, php] } http://symfony.com/doc/current/cookbook/templating/PHP.html, 29 11. 10. Twig, ...?index.html.php, 29 11. 11. Twig, ...? , 29 11. 12. Twig, ...? require_once /path/to/lib/Twig/Autoloader.php; Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem(/path/to/templates); $twig = new Twig_Environment($loader, array( cache => /path/to/compilation_cache, )); echo $twig->render(index.html, array(twitter => #sfcampua));, 29 11. 13. Twig, ...?{% extends "layout.html" %}{% block content %}Symfony Camp UAtwitter hash {{ twitter }}!{% endblock %}, 29 11. 14. Twig, ...? , 29 11. 15. Twig, ...? Sandbox..., 29 11. 16. Twig, ...?{# ... #} {% ... %} {{ ... }} , 29 11. 17. Twig, ...? {% if user is defined %} !! {{ user.name }} !! {{ now | date(d.m.Y) }} {% endif %}, 29 11. 18. Twig, ...? , 29 11. 19. Twig, ...? ! ! {{ user.name }} {{ photo }}, 29 11. 20. Twig, ...? -, 29 11. 21. Twig, ...? {% if user is defined %} ! ! ... {% endif %}, 29 11. 22. Twig, ...? {% spaceless %}

  • XXX
  • ... {% endspaceless %}, 29 11. 23. Twig, ...?
    • XXX
    • ..., 29 11. 24. Twig, ...?setif ... else for includeblock, 29 11. 25. Twig, ...? {# if user is defined #} {#!! ...endif #}, 29 11. 26. Twig, ...? , 29 11. 27. Twig, ...? {% set foo = foo %} {{ foo }} {% set foo = [1, 2] %} {{ foo.0 }} {% set foo = {foo: bar} %} {{ foo.bar }}, 29 11. 28. Twig, ...? , 29 11. 29. Twig, ...?array, [] {% for list in [one, two] %} ... {% endfor %}, 29 11. 30. Twig, ...?hash, {} {% for key, val in {en: US, de: DE} %} ... {% endfor %}, 29 11. 31. Twig, ...?, 29 11. 32. Twig, ...? {{ 1 + 2 }} {{ con~cat }} {% for i in a..z %} {{ i }} {% endfor %}, 29 11. 33. Twig, ...?, 29 11. 34. Twig, ...? {{ user.name | upper }}, 29 11. 35. Twig, ...? {{ now | date(d.m.Y) }}, 29 11. 36. Twig, ...?{{ list | join(,) }}, 29 11. 37. Twig, ...?{{ title | striptags | upper }}, 29 11. 38. Twig, ...?, 29 11. 39. Twig, ...?range(0, 3){% for i in range(0, 3) %}{{ i }},{% endfor %}, 29 11. 40. Twig, ...?, 29 11. 41. Twig, ...?{% extends RopacGalleryFrontendBundle::layout.html.twig %}{% block page_class %} page_artist_news {% endblock %}{% block mobile_menu %}{% include RopacGalleryFrontendBundle:Artist:mobile_menu.html.twig with{active: news} %}{% endblock %}{% block content %}{{artist.firstname}} {{artist.lastname}}{% include RopacGalleryFrontendBundle:Artist:submenu.html.twig with{artist: artist, active: news} %}{% include RopacGalleryFrontendBundle:News:list.html.twig with {news:news} %} {{ parent() }}{% endblock %}, 29 11. 42. Twig, ...?, 29 11. 43. Twig, ...?{{ user.name|e }}{{ user.email|e(js) }}, 29 11. 44. Twig, ...?{% autoescape true %} Everything will be automatically escaped in this block{% endautoescape %}, 29 11. 45. Twig, ...?, 29 11. 46. Twig, ...?{% macro input(name, value, type, size) %}{% endmacro %}, 29 11. 47. Twig, ...?{% import "forms.html" as forms %}

      {{ forms.input(username) }}

      , 29 11. 48. Twig, ...?, 29 11. 49. Twig, ...? twig extensions, 29 11. 50. Twig, ...? , 29 11. 51. Twig, ...?extensions , 29 11. 52. Twig, ...?namespace RopacGalleryBundleExtension;class RopacExtension extends Twig_Extension{public function getFilters(){return array(emailize =>new Twig_Filter_Method($this, emailize));}public function getName(){return ropac_extension;}}, 29 11. 53. Twig, ...?config.yml services.ymlservices:twig.extension.ropac:class: RopacGalleryBundleExtensionRopacExtensiontags:- { name: twig.extension }, 29 11. 54. Twig, ...?namespace RopacGalleryBundleExtension;class RopacExtension extends Twig_Extension{.../*** Transfom emails into clickable mailto links* @param string $text* @return string*/public function emailize($text){ return preg_replace(/([w.!#$%-+.]+@[A-Za-z0-9-]+(.[A-Za-z0-9-]+)+)/, 1, $text);}...}, 29 11. 55. Twig, ...?{{ user.email | emailize }}, 29 11. 56. Twig, ...? twig , 29 11. 57. Twig, ...?, 29 11. 58. Twig, ...? php object, 29 11. 59. Twig, ...? , 29 11. 60. Twig, ...?- , 29 11. 61. Twig, ...? smarty 3.x nativ php http://habrahabr.ru/blogs/php/128083/, 29 11. 62. Twig, ...?,, 29 11. 63. Twig, ...?twig , 29 11. 64. Twig, ...? , , 29 11. 65. Twig, ...? , 29 11. 66. Twig, ...? twig , 29 11. 67. Twig, ...?Doctrine 2Symfony 2, 29 11. 68. Twig, ...? http://david.heinemeierhansson.com/arc/000405.html, 29 11. 69. Twig, ...?native php, 29 11. 70. Twig, ...?+Templating component, 29 11. 71. Twig, ...? layouts , 29 11. 72. Twig, ...? ?, 29 11. 73. Twig, ...? !, 29 11. 74. Twig, ...? ?, 29 11. 75. Twig, ...?Alex Demchenkohttp://451f.com.uahttp://lazy-ants.de, 29 11.