-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Tested on Windows 10 with lustache 1.3.1-0 and Lua 5.1.5.
While trying to render some of the examples from the readme I got the following error:
lua: .\lustache.lua:404: attempt to call method 'lookup' (a nil value)
stack traceback:
.\lustache.lua:404: in function '_name'
.\lustache.lua:202: in function <.\lustache.lua:188>
(tail call): ?
.\lustache.lua:347: in function '_section'
.\lustache.lua:194: in function <.\lustache.lua:188>
(tail call): ?
(tail call): ?
test-lustache-sections.lua:18: in main chunk
[C]: ?The test file was
local lustache = require "lustache"
local view_model, template
view_model = {
stooges = {
{ name = "Moe" },
{ name = "Larry" },
{ name = "Curly" },
}
}
template = [[
{{#stooges}}
* {{name}}
{{/stooges}}
]]
print(lustache:render(template, view_model))The first bug I found was in the function Context:lookup(name), where the call to string_find interprets "." as a pattern (search any character). The line
if string_find(name, ".") > 0 thenshould be changed to
if string_find(name, ".", 1, true) thenThe second bug is when the function Context:new(view, parent) sets the wrong metatable when called from Renderer:_section(token, context, callback, originalTemplate). My workaround was to change the two callback(context:push(v), self) calls into callback(Context:push(v), self).
Metadata
Metadata
Assignees
Labels
No labels