为液体模板引擎实现布局标签
我想主题化我的博客,使用液体模板引擎,但默认情况下,该引擎只支持一些基本标签,我想编写自定义标签 {%layout'layout_name'%}
布局文件:dark.liquid
<html>
...
{% content_for_body %}
...
</html>
和模板文件:blog.liquid
{% layout 'dark' %}
welcome to my blog!
并输出
<html>
...
welcome to my blog!
...
</html>
谢谢!
I want to themed my blog that use liquid template engine, but default, the engine only support some basic tags, I want to write custom tag {% layout 'layout_name' %}
Layout file: dark.liquid
<html>
...
{% content_for_body %}
...
</html>
And template file: blog.liquid
{% layout 'dark' %}
welcome to my blog!
And output
<html>
...
welcome to my blog!
...
</html>
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为这样的事情可能除了在传递
blog.liquid
的其余部分之前抓取第一行并提取布局名称之外,例如:它也应该是“{{ content_for_body }}"; “{% ... %}”用于标记块,如 if 语句。
I don't think that something like this is possibly except for grabbing the first line and extracting the layout name before passing the rest of
blog.liquid
in, for example:Also it should be "{{ content_for_body }}"; "{% ... %}" is used for tag blocks like an if statement.