Lines Matching full:view
124 local function rpos(view, s)
126 local c = byte(view, s, s)
136 local function escaped(view, s)
137 if s > 1 and byte(view, s - 1, s - 1) == BSOL then
138 if s > 2 and byte(view, s - 2, s - 2) == BSOL then
157 return function(view, plain)
158 if plain == true then return view end
159 local path, root = view, template.root
162 if byte(view, 1) == SOL then path = sub(view, 2) end
165 return plain == false and assert(read_file(path)) or read_file(path) or view
170 return function(view) return func(view, false) end
174 return function(view) return func(view, true) end
178 return function(view)
179 return assert(load(view, nil, nil, setmetatable({ template = template }, VIEW_ENV)))
243 function template.new(view, layout)
244 local vt = type(view)
246 if vt == "boolean" then return new(nil, view) end
247 if vt == "table" then return new(view, safe) end
257 context.view = template.process(view, context)
259 layout.view = context.view or EMPTY
265 context.view = template.process(view, context)
267 layout.view = context.view
274 context.view = template.process(view, context)
280 context.view = template.process(view, context)
286 return template.render(view, context or self)
289 return template.process(view, context or self)
326 function template.precompile(view, path, strip, plain)
327 local chunk = dump(template.compile(view, nil, plain), strip ~= false)
336 function template.precompile_string(view, path, strip)
337 return template.precompile(view, path, strip, true)
340 function template.precompile_file(view, path, strip)
341 return template.precompile(view, path, strip, false)
344 function template.compile(view, cache_key, plain)
345 assert(view, "view was not provided for template.compile(view, cache_key, plain)")
347 return load_chunk(template.parse(view, plain)), false
349 cache_key = cache_key or view
352 local func = load_chunk(template.parse(view, plain))
357 function template.compile_file(view, cache_key)
358 return template.compile(view, cache_key, false)
361 function template.compile_string(view, cache_key)
362 return template.compile(view, cache_key, true)
365 function template.parse(view, plain)
366 assert(view, "view was not provided for template.parse(view, plain)")
368 view = template.load(view, plain)
369 if byte(view, 1, 1) == ESC then return view end
378 local i, s = 1, find(view, "{", 1, true)
380 local t, p = byte(view, s + 1, s + 1), s + 2
382 local e = find(view, "}}", p, true)
384 local z, w = escaped(view, s)
387 c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
395 c[j+1] = visit(visitors, trim(sub(view, p, e - 1)), "{")
402 local e = find(view, "*}", p, true)
404 local z, w = escaped(view, s)
407 c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
415 c[j+1] = visit(visitors, trim(sub(view, p, e - 1)), "*")
422 local e = find(view, "%}", p, true)
424 local z, w = escaped(view, s)
428 c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
435 if byte(view, n, n) == LF then
438 local r = rpos(view, s - 1)
441 c[j+1] = visit(visitors, sub(view, i, r))
445 c[j] = visit(visitors, trim(sub(view, p, e - 1)), "%")
452 local e = find(view, ")}", p, true)
454 local z, w = escaped(view, s)
457 c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
464 local f = visit(visitors, sub(view, p, e - 1), "(")
483 local e = find(view, "]}", p, true)
485 local z, w = escaped(view, s)
488 c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
496 c[j+1] = visit(visitors, trim(sub(view, p, e - 1)), "[")
503 local e = find(view, "-}", p, true)
505 local x, y = find(view, sub(view, s, e + 1), e + 2, true)
507 local z, w = escaped(view, s)
511 c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
519 if byte(view, y, y) == LF then
522 local b = trim(sub(view, p, e - 1))
526 c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
531 c[j+1] = visit(visitors, sub(view, e + 2, x))
535 if byte(view, x, x) == LF then
538 local r = rpos(view, s - 1)
541 c[j+1] = visit(visitors, sub(view, i, r))
548 c[j+3] = visit(visitors, sub(view, e + 2, x), "-", b)
557 local e = find(view, "#}", p, true)
559 local z, w = escaped(view, s)
562 c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
570 if byte(view, e, e) == LF then
577 s = find(view, "{", s + 1, true)
579 s = sub(view, i)
586 …c[j] = "return layout and include(layout,setmetatable({view=table.concat(___),blocks=blocks},{__in…
590 function template.parse_file(view)
591 return template.parse(view, false)
594 function template.parse_string(view)
595 return template.parse(view, true)
598 function template.process(view, context, cache_key, plain)
599 assert(view, "view was not provided for template.process(view, context, cache_key, plain)")
600 return template.compile(view, cache_key, plain)(context)
603 function template.process_file(view, context, cache_key)
604 assert(view, "view was not provided for template.process_file(view, context, cache_key)")
605 return template.compile(view, cache_key, false)(context)
608 function template.process_string(view, context, cache_key)
609 assert(view, "view was not provided for template.process_string(view, context, cache_key)")
610 return template.compile(view, cache_key, true)(context)
613 function template.render(view, context, cache_key, plain)
614 assert(view, "view was not provided for template.render(view, context, cache_key, plain)")
615 template.print(template.process(view, context, cache_key, plain))
618 function template.render_file(view, context, cache_key)
619 assert(view, "view was not provided for template.render_file(view, context, cache_key)")
620 template.render(view, context, cache_key, false)
623 function template.render_string(view, context, cache_key)
624 assert(view, "view was not provided for template.render_string(view, context, cache_key)")
625 template.render(view, context, cache_key, true)