]> gitweb.factorcode.org Git - factor.git/blob - basis/html/templates/chloe/components/components.factor
e8703a123529ddf8a6fac2dd9cb17a29b8b5e7c4
[factor.git] / basis / html / templates / chloe / components / components.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs sequences kernel parser fry quotations
4 classes.tuple
5 html.components
6 html.templates.chloe.compiler
7 html.templates.chloe.syntax ;
8 IN: html.templates.chloe.components
9
10 : singleton-component-tag ( tag class -- )
11     [ "name" required-attr compile-attr ]
12     [ literalize [ render ] [code-with] ]
13     bi* ;
14
15 : CHLOE-SINGLETON:
16     scan-word
17     [ name>> ] [ '[ , singleton-component-tag ] ] bi
18     define-chloe-tag ;
19     parsing
20
21 : compile-component-attrs ( tag class -- )
22     [ attrs>> [ drop main>> "name" = not ] assoc-filter ] dip
23     [ all-slots swap '[ name>> , at compile-attr ] each ]
24     [ [ boa ] [code-with] ]
25     bi ;
26
27 : tuple-component-tag ( tag class -- )
28     [ drop "name" required-attr compile-attr ] [ compile-component-attrs ] 2bi
29     [ render ] [code] ;
30
31 : CHLOE-TUPLE:
32     scan-word
33     [ name>> ] [ '[ , tuple-component-tag ] ] bi
34     define-chloe-tag ;
35     parsing