html.templates: adding t:script and t:write-script.

flac
John Benediktsson 2020-03-01 12:05:59 -08:00 committed by Steve Ayerhart
parent 6643e97b2c
commit fac013d307
No known key found for this signature in database
GPG Key ID: 5BFD39C5359E967D
3 changed files with 28 additions and 0 deletions

View File

@ -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." }

View File

@ -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 ;

View File

@ -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
[