html.templates: adding meta tag and some chloe tests.
parent
94378fb7c2
commit
2597a4a8f6
|
@ -194,3 +194,21 @@ TUPLE: person first-name last-name ;
|
||||||
] run-template
|
] run-template
|
||||||
] with-scope
|
] with-scope
|
||||||
] [ error>> tag-not-allowed-here? ] must-fail-with
|
] [ error>> tag-not-allowed-here? ] must-fail-with
|
||||||
|
|
||||||
|
{ "This is <style type=\"text/css\"> * { font-family: monospace; } </style>" } [
|
||||||
|
SBUF" " clone style [
|
||||||
|
[ "test16" test-template call-template ] run-template
|
||||||
|
] with-variable
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{ "<script type=\"text/javascript\"> function testAlerts() { window.alert(\"Hello, world!\");} </script>" } [
|
||||||
|
SBUF" " clone script [
|
||||||
|
[ "test17" test-template call-template ] run-template
|
||||||
|
] with-variable
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
{ "<meta name=\"author\" content=\"John Doe\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"/>" } [
|
||||||
|
V{ } clone meta [
|
||||||
|
[ "test18" test-template call-template ] run-template
|
||||||
|
] with-variable
|
||||||
|
] unit-test
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs html.components html.forms
|
USING: accessors arrays assocs fry html.components html.forms
|
||||||
html.templates html.templates.chloe.compiler
|
html.templates html.templates.chloe.compiler
|
||||||
html.templates.chloe.components html.templates.chloe.syntax
|
html.templates.chloe.components html.templates.chloe.syntax
|
||||||
io.encodings.utf8 io.files io.files.info kernel logging make
|
io.encodings.utf8 io.files io.files.info kernel logging make
|
||||||
|
@ -49,6 +49,14 @@ CHLOE: write-script
|
||||||
[XML <script type="text/javascript"> <-> </script> XML]
|
[XML <script type="text/javascript"> <-> </script> XML]
|
||||||
] [xml-code] ;
|
] [xml-code] ;
|
||||||
|
|
||||||
|
CHLOE: meta
|
||||||
|
[ "name" optional-attr ]
|
||||||
|
[ "content" optional-attr ] bi
|
||||||
|
'[ _ _ add-meta ] [code] ;
|
||||||
|
|
||||||
|
CHLOE: write-meta
|
||||||
|
drop [ get-meta ] [xml-code] ;
|
||||||
|
|
||||||
CHLOE: even
|
CHLOE: even
|
||||||
[ "index" value even? swap when ] process-children ;
|
[ "index" value even? swap when ] process-children ;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
! Copyright (C) 2008, 2009 Slava Pestov.
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel fry io io.encodings.utf8 io.files
|
USING: accessors arrays assocs boxes continuations debugger io
|
||||||
debugger prettyprint continuations namespaces boxes sequences
|
io.encodings.utf8 io.files io.streams.string kernel namespaces
|
||||||
arrays strings html io.streams.string assocs
|
prettyprint quotations sequences strings xml.data xml.syntax
|
||||||
quotations xml.data xml.writer xml.syntax ;
|
xml.writer ;
|
||||||
|
! USING: accessors kernel fry io io.encodings.utf8 io.files
|
||||||
|
! debugger prettyprint continuations namespaces boxes sequences
|
||||||
|
! arrays strings html io.streams.string assocs
|
||||||
|
! quotations xml.data xml.writer xml.syntax ;
|
||||||
IN: html.templates
|
IN: html.templates
|
||||||
|
|
||||||
MIXIN: template
|
MIXIN: template
|
||||||
|
@ -71,6 +75,19 @@ SYMBOL: script
|
||||||
: write-script ( -- )
|
: write-script ( -- )
|
||||||
get-script write ;
|
get-script write ;
|
||||||
|
|
||||||
|
SYMBOL: meta
|
||||||
|
|
||||||
|
: add-meta ( name content -- )
|
||||||
|
2array meta get push ;
|
||||||
|
|
||||||
|
: get-meta ( -- xml )
|
||||||
|
meta get [
|
||||||
|
[XML <meta name=<-> content=<->/> XML]
|
||||||
|
] { } assoc>map ;
|
||||||
|
|
||||||
|
: write-meta ( -- )
|
||||||
|
get-meta write-xml ;
|
||||||
|
|
||||||
SYMBOL: atom-feeds
|
SYMBOL: atom-feeds
|
||||||
|
|
||||||
: add-atom-feed ( title url -- )
|
: add-atom-feed ( title url -- )
|
||||||
|
@ -104,6 +121,7 @@ M: f call-template* drop call-next-template ;
|
||||||
title [ [ <box> ] unless* ] change
|
title [ [ <box> ] unless* ] change
|
||||||
style [ [ SBUF" " clone ] unless* ] change
|
style [ [ SBUF" " clone ] unless* ] change
|
||||||
script [ [ SBUF" " clone ] unless* ] change
|
script [ [ SBUF" " clone ] unless* ] change
|
||||||
|
meta [ [ V{ } clone ] unless* ] change
|
||||||
atom-feeds [ V{ } like ] change
|
atom-feeds [ V{ } like ] change
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue