html.templates: adding t:script and t:write-script.
parent
6643e97b2c
commit
fac013d307
|
@ -88,6 +88,8 @@ $nl
|
|||
{ { $snippet "t:write-title" } "Renders the child's title. Intended for use in a child template." }
|
||||
{ { $snippet "t:style" } { "Adds CSS markup from the file named by the " { $snippet "t:include" } " attribute. Intended for use in a child template." } }
|
||||
{ { $snippet "t:write-style" } "Renders the children's CSS markup. Intended for use in a master template." }
|
||||
{ { $snippet "t:script" } { "Adds JS from the file named by the " { $snippet "t:include" } " attribute. Intended for use in a child template." } }
|
||||
{ { $snippet "t:write-script" } "Renders the children's JS. Intended for use in a master template." }
|
||||
{ { $snippet "t:atom" } { "Adds an Atom feed link. The attributes are the same as the " { $snippet "t:link" } " tag. Intended for use in a child template. (*)" } }
|
||||
{ { $snippet "t:write-atom" } "Renders the children's list of Atom feed links. Intended for use in a master template. (*)" }
|
||||
{ { $snippet "t:call-next-template" } "Calls the next child template from a master template." }
|
||||
|
|
|
@ -36,6 +36,19 @@ CHLOE: write-style
|
|||
[XML <style type="text/css"> <-> </style> XML]
|
||||
] [xml-code] ;
|
||||
|
||||
CHLOE: script
|
||||
dup "include" optional-attr [
|
||||
utf8 file-contents [ add-script ] [code-with]
|
||||
] [
|
||||
compile-children>string [ add-script ] [code]
|
||||
] ?if ;
|
||||
|
||||
CHLOE: write-script
|
||||
drop [
|
||||
get-script
|
||||
[XML <script type="text/javascript"> <-> </script> XML]
|
||||
] [xml-code] ;
|
||||
|
||||
CHLOE: even
|
||||
[ "index" value even? swap when ] process-children ;
|
||||
|
||||
|
|
|
@ -59,6 +59,18 @@ SYMBOL: style
|
|||
: write-style ( -- )
|
||||
get-style write ;
|
||||
|
||||
SYMBOL: script
|
||||
|
||||
: add-script ( string -- )
|
||||
"\n" script get push-all
|
||||
script get push-all ;
|
||||
|
||||
: get-script ( -- string )
|
||||
script get >string ;
|
||||
|
||||
: write-script ( -- )
|
||||
get-script write ;
|
||||
|
||||
SYMBOL: atom-feeds
|
||||
|
||||
: add-atom-feed ( title url -- )
|
||||
|
@ -91,6 +103,7 @@ M: f call-template* drop call-next-template ;
|
|||
[
|
||||
title [ [ <box> ] unless* ] change
|
||||
style [ [ SBUF" " clone ] unless* ] change
|
||||
script [ [ SBUF" " clone ] unless* ] change
|
||||
atom-feeds [ V{ } like ] change
|
||||
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue