twig模板常用语句实例小结_PHP

WBOY
Release: 2016-05-27 10:37:28
Original
964 people have browsed it

本文实例讲述了twig模板常用语句。分享给大家供大家参考,具体如下:

最近写的静态页面需要套symfony模板,所以将使用到的twig模板语句做一个总结:希望能帮到初学者。

代码结构如下:

{% extends '::l_sh_base.html.twig' %} //引入的base模板
{% block title %} //网页标题
商户中心-维修分类
{% endblock %}
{% block stylesheets %} //引入的css或js文件
{{ parent() }}
<link href="{{ asset('bundles/zmshop/css/l_maintenance_classification.css') }}" rel="stylesheet" type="text/css">
{% endblock %}
{% block header %} //网页头部内容
{{ parent() }}
{% endblock %}
{% block body %} //网页主体内容
<!-- {{ dump(appliance) }} -->
{% for item in appliance %} //for循环语句
{{ item.appliance_name }}
{% endfor %}
src="{{ asset('image/appliance/') }}{{ item.image }}" //图片路径
{{ path('zm_shop_appliance_add') }} //href跳转路径
{% if item.status == 1 %}  //if语句
class="marquee"
{% endif %}
{% endblock %}
{% block footer %} //网页底部内容
{{ parent() }}
{% endblock %}

Copy after login

需要注意的是:在%外部不能写HTML注释

本文永久地址:http://blog.it985.com/12383.html
本文出自 IT985博客 ,转载时请注明出处及相应链接。

更多关于PHP模板相关内容感兴趣的读者可查看本站专题:《PHP模板技术总结》、《smarty模板入门基础教程》、《codeigniter入门教程》及《ThinkPHP入门教程》

希望本文所述对大家PHP程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!