]> gitweb.factorcode.org Git - factor.git/blob - basis/html/templates/chloe/syntax/syntax.factor
Merge branch 'master' into experimental (untested!)
[factor.git] / basis / html / templates / chloe / syntax / syntax.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 IN: html.templates.chloe.syntax
4 USING: accessors kernel sequences combinators kernel namespaces
5 classes.tuple assocs splitting words arrays memoize parser lexer
6 io io.files io.encodings.utf8 io.streams.string
7 unicode.case mirrors fry math urls
8 multiline xml xml.data xml.writer xml.utilities
9 html.elements
10 html.components
11 html.templates ;
12
13 SYMBOL: tags
14
15 tags global [ H{ } clone or ] change-at
16
17 : define-chloe-tag ( name quot -- ) swap tags get set-at ;
18
19 : CHLOE:
20     scan parse-definition define-chloe-tag ; parsing
21
22 : chloe-ns "http://factorcode.org/chloe/1.0" ; inline
23
24 : chloe-name ( string -- name )
25     name new
26         swap >>main
27         chloe-ns >>url ;
28
29 : required-attr ( tag name -- value )
30     dup chloe-name rot at*
31     [ nip ] [ drop " attribute is required" append throw ] if ;
32
33 : optional-attr ( tag name -- value )
34     chloe-name swap at ;