luarocks install lua-resty-templatelocation /{ root html; content_by_lua ‘ local template = require "resty.template" template.render("view.html",{ message ="Hello, World!"})‘;}<!DOCTYPE html><html><body><h1>{{message}}</h1></body></html>http { server { set $template_root /usr/local/openresty/nginx/html/templates; location /{ root html; content_by_lua ‘ local template = require "resty.template" template.render("view.html",{ message ="Hello, World!"})‘;}}}http { server { set $template_location /templates; location /{ root html; content_by_lua ‘ local template = require "resty.template" template.render("view.html",{ message ="Hello, World!"})‘;} location /templates { internal; alias html/templates/;}}https://github.com/bungle/lua-resty-templatelua resty template && openresty 使用
原文:http://www.cnblogs.com/rongfengliang/p/6666598.html