! See http://factorcode.org/license.txt for BSD license.
USING: continuations sequences kernel namespaces debugger
combinators math quotations generic strings splitting accessors
-assocs fry vocabs.parser parser lexer io io.files call
-io.streams.string io.encodings.utf8 html.templates ;
+assocs fry vocabs.parser parser parser.notes lexer io io.files
+io.streams.string io.encodings.utf8 html.templates compiler.units ;
IN: html.templates.fhtml
! We use a custom lexer so that %> ends a token even if not
M: template-lexer skip-word
[
{
- { [ 2dup nth CHAR: " = ] [ drop 1+ ] }
+ { [ 2dup nth CHAR: " = ] [ drop 1 + ] }
{ [ 2dup swap tail-slice "%>" head? ] [ drop 2 + ] }
[ f skip ]
} cond
drop
] if ;
-: %> lexer get parse-%> ; parsing
+SYNTAX: %> lexer get parse-%> ;
: parse-template-lines ( lines -- quot )
<template-lexer> [
: parse-template ( string -- quot )
[
+ [
"quiet" on
parser-notes off
- "html.templates.fhtml" use+
+ "html.templates.fhtml" use-vocab
string-lines parse-template-lines
- ] with-file-vocabs ;
+ ] with-file-vocabs
+ ] with-compilation-unit ;
: eval-template ( string -- )
- parse-template call ;
+ parse-template call( -- ) ;
TUPLE: fhtml path ;