2008-06-01 18:22:39 -04:00
|
|
|
! Copyright (C) 2008 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-05-15 00:23:06 -04:00
|
|
|
USING: accessors sequences combinators kernel namespaces classes.tuple
|
|
|
|
assocs splitting words arrays memoize parser lexer io io.files
|
2016-03-31 02:29:48 -04:00
|
|
|
io.encodings.utf8 io.streams.string unicode mirrors fry math urls
|
2009-05-15 00:23:06 -04:00
|
|
|
multiline xml xml.data xml.writer xml.syntax html.components
|
2008-06-01 18:22:39 -04:00
|
|
|
html.templates ;
|
2009-05-15 00:23:06 -04:00
|
|
|
IN: html.templates.chloe.syntax
|
2008-06-01 18:22:39 -04:00
|
|
|
|
|
|
|
SYMBOL: tags
|
|
|
|
|
2009-02-10 17:16:12 -05:00
|
|
|
tags [ H{ } clone ] initialize
|
2008-06-01 18:22:39 -04:00
|
|
|
|
2008-06-02 16:00:03 -04:00
|
|
|
: define-chloe-tag ( name quot -- ) swap tags get set-at ;
|
2008-06-01 18:22:39 -04:00
|
|
|
|
2009-03-21 02:27:50 -04:00
|
|
|
SYNTAX: CHLOE:
|
2011-09-27 16:20:07 -04:00
|
|
|
scan-token parse-definition define-chloe-tag ;
|
2008-06-01 18:22:39 -04:00
|
|
|
|
2009-02-23 22:40:17 -05:00
|
|
|
CONSTANT: chloe-ns "http://factorcode.org/chloe/1.0"
|
2008-06-01 18:22:39 -04:00
|
|
|
|
2009-01-28 18:49:21 -05:00
|
|
|
: chloe-name? ( name -- ? )
|
|
|
|
url>> chloe-ns = ;
|
|
|
|
|
|
|
|
XML-NS: chloe-name http://factorcode.org/chloe/1.0
|
2008-06-01 18:22:39 -04:00
|
|
|
|
|
|
|
: required-attr ( tag name -- value )
|
2009-02-02 14:43:54 -05:00
|
|
|
[ nip ] [ chloe-name attr ] 2bi
|
|
|
|
[ ] [ " attribute is required" append throw ] ?if ;
|
2008-06-01 18:22:39 -04:00
|
|
|
|
|
|
|
: optional-attr ( tag name -- value )
|
2009-01-28 18:49:21 -05:00
|
|
|
chloe-name attr ;
|