Closed cuiweixie closed 4 years ago
<a href ="{%
local function echo(s)
___[#___+1] =s
end
echo("http://www.baidu.com")
%}">baidu
I look into the code. and find this solution, is it ok?
Why not:
{{message)}
{{"ssss"}}
sometimes the "ssss" maybe generated by some lua code.
Then just put that code in there?
{{ run_my_code("yeah!") }}
Another example:
{{ (function() return "sss" end)() }}
I think a phper will feel more comfortable if we has a echo function. I am trying to move some php codes to openresty.
a echo func could make you template more readable
Well, I can think about it, but if you are putting code (like a lot of it) in template, you are possibly doing it wrong (aka spaghetti).
i will add it in resty.template.
Yes, PRs welcome. Not sure though if I will include it, but you can send it. Or just fork it.
OK
https://github.com/bungle/lua-resty-template/pull/28 here comes the PR.
@cuiweixie, thanks for the PR. Let's see if others vote this as well.
like this: {message} {% print("ssss") %} output: sssshello world expecting: hello wordssss the sss show not be at the begin?