leafo / etlua Goto Github PK
View Code? Open in Web Editor NEWEmbedded Lua templates
Embedded Lua templates
/usr/local/share/lua/5.1/lapis/application.lua:526: attempt to call a table value
stack traceback:
Traceback
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/lapis/application.lua:526: in function 'handler'
/usr/local/share/lua/5.1/lapis/application.lua:338: in function 'resolve'
/usr/local/share/lua/5.1/lapis/application.lua:347: in function </usr/local/share/lua/5.1/lapis/application.lua:345>
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/lapis/application.lua:345: in function 'dispatch'
/usr/local/share/lua/5.1/lapis/nginx.lua:170: in function </usr/local/share/lua/5.1/lapis/nginx.lua:168>
Get this when running
etlua = require 'etlua'
lapis.serve class extends lapis.Application
[index: '/:slug']: capture_errors =>
-- ... some code
template = etlua.compile '<span><%= slug%></span>'
-- ... some more code
in a lapis application.
This works in a console application:
etlua = require 'etlua'
template = etlua.compile '<span><%= slug%></span>'
Re: #5
Is there a chance the syntax could be extended, following the Lua pattern of multiline strings, to something like:
[==[ variable nuimber of extensions as long as they're equal ]==]
<==% something like this or %==>
<%%% variable percents? %%%>
Not sure the optimal way, but something like that to allow nesting of templating tags.
PHP like templating would be quite useful. Is there a equivalent in etLua?
Hi, @leafo
When I use chart.js , it uses a legend template filed like this:
//String - A legend template
legendTemplate: '<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].lineColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>',
etlua should not translate "<%" and "%>" in this string, how can I escape them?
I've created etlua syntax highlighting for vim.
It's available for etlua files (with HTML) and for plain text files, in case you want to template other file types.
I had a partially working one for Sublime Text as well but haven't looked at it in a while. If anyone is interested in that let me know, and I'll see if I can dig it up.
I would like to understand how to deal with sub-template when we are outside of Lapis?
I had tested something like that
<!-- templates/test.etlua -->
<html>
<% etlua.render("templates.partials.head") %>
<body>
Hello <%- title %>
<%- content %>
</body>
</html>
But it's not working ... I presume it's a package.path
problem, but i don't know how to fix it.
Thanks for your help!
Lexer is just made. Note- I could not make it highlight Lua inside quoted strings.
To install: Plugins / Addon Manager / Install, type "etlua" to find it.
@Artem3213212
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.