[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-dev
Subject:    =?utf-8?Q?[jira]_[Updated]_(VELOCITY-885)_=E5=B8=8C=E6=9C=9B_Velocit?= =?utf-8?Q?y-tools-layout_=E8=
From:       "Wang yongshan (JIRA)" <jira () apache ! org>
Date:       2017-08-14 9:28:00
Message-ID: JIRA.13094420.1502702491000.23815.1502702880134 () Atlassian ! JIRA
[Download RAW message or body]


     [ https://issues.apache.org/jira/browse/VELOCITY-885?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]

Wang yongshan updated VELOCITY-885:
-----------------------------------
    Description: 
我在使用 Python 模板引擎 Jinja2(http://jinja.pocoo.org/)时,发现 Jinja2 \
的 *{% block title %} Default title {% endblock %}* 和  *{{ super() }}* \
                语法特性在 Layout 继承时非常有用,例如:
*default-layout.html*
{code:html}
<head>
  <title>{% block title %}Default title{% endblock %}</title>
  {% block head %}
    <link rel="stylesheet" href="style.css"/>
  {% endblock %}
</head>
<body>
{% block content %} {% endblock %}
</body>
{code}

*child.html*
{code:html}
{% extends "default-layout.html" %}
{% block title %}User Manager{% endblock %}
{% block head %}
   {{ super() }}
   <style type="text/css">
   .important {font-size:20px;font-weight:bold;}
   </style>
{% endblock %}
{% block content %}
<h2>User Manager</h2>
...
{% endblock %}
{code}

这种特性在 *局部大块内容进行复用/替换* 时非常有用,能提高 \
Web 页面的开发效率和减少一定的代 量。

 此,我在 Velocity-1.7.x 中进行了修改,增 了: *#block()  #end* \
                、*#override() #end* 和 *#super()* 指令,用法如下:
*default-layout.html*
{code:html}
<head>
  <title>#block("title") Default title #end</title>
  #block("head")
    <link rel="stylesheet" href="style.css"/>
  #end
</head>
<body>
$!{ screen_content }
</body>
{code}

*child.html*
{code:html}
#override("title") User Manager #end
#override("head") 
   #super()
   <style type="text/css">
   .important {font-size:20px;font-weight:bold;}
   </style>
#end

<h2>User Manager</h2>
...
{code}

希望 Velocity-2.x 后面也能够增 类似 Jinja2 的 block、super 等指令。

祝愿 Velocity 越来越好!


  was:
我在使用 Python 模板引擎 Jinja2(http://jinja.pocoo.org/)时,发现 Jinja2 \
的 *{% block title %} Default title {% endblock %}* 和  *{{ super() }}* \
                语法特性在 Layout 继承时非常有用,例如:
*default-layout.html*
{code:html}
<head>
  <title>{% block title %}Default title{% endblock %}</title>
  {% block head %}
    <link rel="stylesheet" href="style.css"/>
  {% endblock %}
</head>
<body>
{% block content %} {% endblock %}
</body>
{code}

*child.html*
{code:html}
{% extends "default-layout.html" %}
{% block title %}User Manager{% endblock %}
{% block head %}
   {{ super() }}
   <style type="text/css">
   .important {font-size:20px;font-weight:bold;}
   </style>
{% endblock %}
{% block content %}
<h2>User Manager</h2>
...
{% endblock %}
{code}

这种特性在 *局部大块内容进行复用/替换* 时非常有用,能提高 \
Web 页面的开发效率和减少一定的代 量。

 此,我在 Velocity-1.7.x 中进行了修改,增 了: *#block()  #end* \
                、*#override() #end* 和 *#super()* 指令,用法如下:
*default-layout.html*
{code:html}
<head>
  <title>#block("title") Default title #end</title>
  #block("head")
    <link rel="stylesheet" href="style.css"/>
  #end
</head>
<body>
$!{ screen_content }
</body>
{code}

*child.html*
{code:html}
#override("title") User Manager #end
#override("head") 
   #super()
   <style type="text/css">
   .important {color: #cc0000; font-weight:bold;}
   </style>
#end

<h2>User Manager</h2>
...
{code}

希望 Velocity-2.x 后面也能够增 类似 Jinja2 的 block、super 等指令。

祝愿 Velocity 越来越好!



> 希望 Velocity-tools-layout 能够增  #block()、#super() 模板指令
> ----------------------------------------------------
> 
> Key: VELOCITY-885
> URL: https://issues.apache.org/jira/browse/VELOCITY-885
> Project: Velocity
> Issue Type: New Feature
> Components: Engine
> Affects Versions: 2.1.x
> Reporter: Wang yongshan
> Priority: Minor
> Fix For: 2.1.x
> 
> 
> 我在使用 Python 模板引擎 Jinja2(http://jinja.pocoo.org/)时,发现 Jinja2 \
> 的 *{% block title %} Default title {% endblock %}* 和  *{{ super() }}* \
>                 语法特性在 Layout 继承时非常有用,例如:
> *default-layout.html*
> {code:html}
> <head>
> <title>{% block title %}Default title{% endblock %}</title>
> {% block head %}
> <link rel="stylesheet" href="style.css"/>
> {% endblock %}
> </head>
> <body>
> {% block content %} {% endblock %}
> </body>
> {code}
> *child.html*
> {code:html}
> {% extends "default-layout.html" %}
> {% block title %}User Manager{% endblock %}
> {% block head %}
> {{ super() }}
> <style type="text/css">
> .important {font-size:20px;font-weight:bold;}
> </style>
> {% endblock %}
> {% block content %}
> <h2>User Manager</h2>
> ...
> {% endblock %}
> {code}
> 这种特性在 *局部大块内容进行复用/替换* 时非常有用,能提高 \
> Web 页面的开发效率和减少一定的代 量。  此,我在 \
> Velocity-1.7.x 中进行了修改,增 了: *#block()  #end* 、*#override() \
>                 #end* 和 *#super()* 指令,用法如下:
> *default-layout.html*
> {code:html}
> <head>
> <title>#block("title") Default title #end</title>
> #block("head")
> <link rel="stylesheet" href="style.css"/>
> #end
> </head>
> <body>
> $!{ screen_content }
> </body>
> {code}
> *child.html*
> {code:html}
> #override("title") User Manager #end
> #override("head") 
> #super()
> <style type="text/css">
> .important {font-size:20px;font-weight:bold;}
> </style>
> #end
> <h2>User Manager</h2>
> ...
> {code}
> 希望 Velocity-2.x 后面也能够增 类似 Jinja2 的 block、super \
> 等指令。 祝愿 Velocity 越来越好!



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic