Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use javascript smarty template inheritance

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian for you to introduce in detail the "javascript smarty template inheritance how to use", the content is detailed, the steps are clear, the details are handled properly, I hope this "javascript smarty template inheritance how to use" article can help you solve doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.

Define

Inheritance is a concept derived from object-oriented programming. Template inheritance allows you to define one or more parent templates and provide them to child templates for extension. Extended inheritance means that child templates can cover some or all of the block areas of the parent template.

Characteristics

The inheritance structure can be multi-layered, so you can inherit from one file, which in turn inherits from other files.

Outside the {block} block that overrides the parent template, the child template cannot define anything, and anything other than {block} will be automatically ignored.

The subtemplate inherits using the {extends} tag, which must be placed on the first line of the subtemplate.

Template inheritance will be compiled into a separate compilation file at compile time, and template inheritance has higher performance than {include}, which contains template functions.

Code

Layout.html (parent template)

{block name=title} default page title {/ block}

{block name=head} {/ block}

{block name=body} {/ block}

Myproject.html (parent template)

{extends file='layout.html'}

{block name=head}

{/ block}

Mypage.html (grandson template)

{extends file='myproject.html'}

{block name=title} my page title {/ block}

{block name=head}

{/ block}

{block name=body} my HTML page content is here {/ block}

$smarty- > display ('mypage.html')

My page title

The content of my HTML page is here

Warm reminder: {extends} has higher performance than {include}.

Read here, this "javascript smarty template inheritance how to use" article has been introduced, want to master the knowledge of this article also need to practice and use to understand, if you want to know more about the article, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report