If you can't read please download the document
Upload
alex-demchenko
View
1.678
Download
1
Tags:
Embed Size (px)
DESCRIPTION
twig tempalte en
Citation preview
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 %}
{{ 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.