html中的方括号是什么意思? [英] What do square brackets mean in html?

查看:810
本文介绍了html中的方括号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在协助一个项目,并且是第一次构建模板,试图将我的头缠在几件事上,但是令我感到困惑的html的某些方面是某些东西放在了方括号中.我以前从未在html中使用过这些,所以我只是想知道它们的用途(当我在浏览器中打开页面时,它们都显示为文本)

I am assisting on a project right now and building out templates for the first time, trying to wrap my head around a few things but one aspect of the html that's confusing me are certain things sitting in square brackets. I've never used these in html before so I'm just wondering what they are for (when I open the page in a browser they all show up as text)

下面是一些代码:

<div class="container">
   [HASBREADCRUMBS]
   <ol class="nav-breadcrumb">
      [BREADCRUMBS]
   </ol>
   [/HASBREADCRUMBS]
   <h1 class="header-title" style="color:[TITLECOLOR];font-size:[TITLESIZE];">[TITLE]</h1>
</div>

推荐答案

它正在使用一些模板引擎,并且在将整个页面解析到输出到浏览器之前.在解析过程中,那些方括号标记可以用作其他标记(取决于所使用的模板引擎).

It's using some templating engine and the whole page is parsed before getting output to the browser. During parsing, those square bracket tags work as something else (depending on the templating engine used).

例如,[HASBREADCRUMBS][/HASBREADCRUMBS]可能表示一段类似于以下内容的代码:

So, for example, [HASBREADCRUMBS] and [/HASBREADCRUMBS] could denote a piece of code that might be similar to:

if (breadcrumbs) {

和:

} // closed if

,并且对于面包屑对象的每个值(无论可能是什么),都会以面包屑值作为其内容([BREADCRUMBS])呈现一个有序的HTML列表.

and for each value of the breadcrumbs object (whatever it might be) one ordered HTML list is rendered with the breadcrumb value as its content ([BREADCRUMBS]).

因此,简而言之:它不是HTML,文件的那部分永远不会到达浏览器,而是在呈现之前转换为适当的HTML(基于条件,也可以使用循环等).

So in short: it's not HTML, that part of the file never reaches the browser but is converted into proper HTML (based on conditions, can also use loops, etc.) before rendering.

这篇关于html中的方括号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆