]> gitweb.factorcode.org Git - factor.git/blob - basis/html/templates/chloe/syntax/syntax.factor
Merge branch 'master' into experimental
[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? ( name -- ? )
25     url>> chloe-ns = ;
26
27 XML-NS: chloe-name http://factorcode.org/chloe/1.0
28
29 : required-attr ( tag name -- value )
30     tuck chloe-name attr
31     [ nip ] [ " attribute is required" append throw ] if* ;
32
33 : optional-attr ( tag name -- value )
34     chloe-name attr ;