OpenResty(5):Openresty 模板渲染
发布日期:2025-04-29 05:00:15 浏览次数:15 分类:精选文章

本文共 558 字,大约阅读时间需要 1 分钟。

1 Lua-Resty??

??Lua-Resty?????????Nginx????????????

2 Nginx??

?Nginx????????????

set $template_root /usr/local/openresty/nginx/html/templates;  default_type text/html;  content_by_lua_file /usr/local/openresty/nginx/conf/*.lua;

3 Lua????

????Lua??????demo.lua?? local template = require "resty.template" content = { message = "Hello, World!", names = {"james", "fox", "tony"} } template.render("demo.html", content)

4 HTML????

????HTML??????demo.html??

openresty template Example

{{ message }}

{% for i, v in ipairs(names) do %}
{{ i }}--{{ v }}
{% endfor %}
上一篇:OpenSearch 使用二三事
下一篇:OpenResty(4):OpenResty快速入门

发表评论

最新留言

感谢大佬
[***.8.128.20]2026年05月26日 11时58分03秒