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 classes.singleton
6 html.templates.chloe.compiler
7 html.templates.chloe.syntax ;
8 IN: html.templates.chloe.components
10 GENERIC: component-tag ( tag class -- )
12 M: singleton-class component-tag ( tag class -- )
13 [ "name" required-attr compile-attr ]
14 [ literalize [ render ] [code-with] ]
17 : compile-component-attrs ( tag class -- )
18 [ attrs>> [ drop main>> "name" = not ] assoc-filter ] dip
19 [ all-slots swap '[ name>> _ at compile-attr ] each ]
20 [ [ boa ] [code-with] ]
23 M: tuple-class component-tag ( tag class -- )
24 [ drop "name" required-attr compile-attr ] [ compile-component-attrs ] 2bi
29 [ name>> ] [ '[ _ component-tag ] ] bi