Symfony - view

Twig 是 快速 ,灵活 ,安全的PHP前端模版。

concise 简洁

熟悉Twig

标记说明 :

  • {{ ... }}: prints the content of a variable or the result of an expression;
输出内容变量或者是表达式的结果。
      
      
<li><a href="http://symfony.com/doc/{{ version }}/book/index.html">The Book</a></li>


  •  {% ... %}: controls the logic of the template; it is used for example to execute for loops and
逻辑控制或者是循环或者是IFELSE
      
      
{% if app.environment == 'dev' %}
<div class="block-configure">
<div class="illustration">
<img src="{{ asset('bundles/acmedemo/images/welcome-configure.gif') }}" alt="Configure your application" />
</div>
<a href="{{ path('_configurator_home') }}" class="sf-button sf-button-selected">
<span class="border-l">
<span class="border-r">
<span class="btn-bg">Configure</span>
</span>
</span>
</a>
</div>
{% endif %}

  •  {# ... #}: allows including comments inside templates.
twig注释部分,并不会展示在网页上。


装饰模版


   
   
{% extends "AcmeDemoBundle::layout.html.twig" %}
{% block title "Hello " ~ name %}
{% block content %}
<h1>Hello {{ name }}!</h1>
{% endblock %}
{% set code = code(_self) %}


继承并重写content内容。


 {% block %}


   
   
{% block head %}
<link rel="icon" sizes="16x16" href="{{ asset('favicon.ico') }}" />
<link rel="stylesheet" href="{{ asset('bundles/acmedemo/css/demo.css') }}" />
{% endblock %}
利用asset引入CSS和img等外部资源。































评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值