] run-template
] with-scope
] [ 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
! Copyright (C) 2008 Slava Pestov.
! 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.chloe.components html.templates.chloe.syntax
io.encodings.utf8 io.files io.files.info kernel logging make
[XML <script type="text/javascript"> <-> </script> XML]
] [xml-code] ;
+CHLOE: meta
+ [ "name" optional-attr ]
+ [ "content" optional-attr ] bi
+ '[ _ _ add-meta ] [code] ;
+
+CHLOE: write-meta
+ drop [ get-meta ] [xml-code] ;
+
CHLOE: even
[ "index" value even? swap when ] process-children ;
! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-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 ;
+USING: accessors arrays assocs boxes continuations debugger io
+io.encodings.utf8 io.files io.streams.string kernel namespaces
+prettyprint quotations sequences strings xml.data 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
MIXIN: template
: write-script ( -- )
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
: add-atom-feed ( title url -- )
title [ [ <box> ] unless* ] change
style [ [ SBUF" " clone ] unless* ] change
script [ [ SBUF" " clone ] unless* ] change
+ meta [ [ V{ } clone ] unless* ] change
atom-feeds [ V{ } like ] change
[