Skip to content

Commit

Permalink
feat(echo) add a echo func that could be use in {% %} (#28)
Browse files Browse the repository at this point in the history
* add echo function like php
* add tostring
* echo accept ... as arg
  • Loading branch information
cuiweixie authored Feb 6, 2020
1 parent b82327d commit 5fd3e56
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/resty/template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ function template.parse(view, plain)
context=... or {}
local function include(v, c) return template.compile(v)(c or context) end
local ___,blocks,layout={},blocks or {}
local function echo(...)
local args = {...}
for i=1,select("#", ...) do
args[i] = tostring(args[i])
end
___[#___+1] = table.concat(args)
end
]] }
local i, s = 1, find(view, "{", 1, true)
while s do
Expand Down

0 comments on commit 5fd3e56

Please sign in to comment.