search
Homephp教程php手册twig模板常用语句实例小结,twig模板小结

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

本文实例讲述了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 %}

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

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

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

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

您可能感兴趣的文章:

  • twig里使用js变量的方法
  • Twig模板引擎用法入门教程
  • 在Yii框架中使用PHP模板引擎Twig的例子
  • twig模板获取全局变量的方法
Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools