]> gitweb.factorcode.org Git - factor.git/blob - basis/html/templates/chloe/syntax/syntax.factor
Switch to https urls
[factor.git] / basis / html / templates / chloe / syntax / syntax.factor
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs kernel lexer namespaces parser sequences
4 xml.data xml.syntax ;
5 IN: html.templates.chloe.syntax
6
7 SYMBOL: chloe-tags
8
9 chloe-tags [ H{ } clone ] initialize
10
11 : define-chloe-tag ( name quot -- ) swap chloe-tags get set-at ;
12
13 SYNTAX: CHLOE:
14     scan-token parse-definition define-chloe-tag ;
15
16 CONSTANT: chloe-ns "https://factorcode.org/chloe/1.0"
17
18 : chloe-name? ( name -- ? )
19     url>> chloe-ns = ;
20
21 XML-NS: chloe-name https://factorcode.org/chloe/1.0
22
23 : required-attr ( tag name -- value )
24     [ nip ] [ chloe-name attr ] 2bi
25     [ ] [ " attribute is required" append throw ] ?if ;
26
27 : optional-attr ( tag name -- value )
28     chloe-name attr ;