You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
18 KiB
HTML
2 lines
18 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>9.7 Tag</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="file:///Users/MB/Library/Racket/6.0.1/doc/local-redirect/local-redirect.js"></script><script type="text/javascript" src="file:///Users/MB/Library/Racket/6.0.1/doc/local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">►</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Pollen:<span class="mywbr"> </span> the book is a program</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="Installation.html" class="tocviewlink" data-pltdoc="x">Installation</a></td></tr><tr><td align="right">2 </td><td><a href="quick-tour.html" class="tocviewlink" data-pltdoc="x">Quick tour</a></td></tr><tr><td align="right">3 </td><td><a href="Backstory.html" class="tocviewlink" data-pltdoc="x">Backstory</a></td></tr><tr><td align="right">4 </td><td><a href="big-picture.html" class="tocviewlink" data-pltdoc="x">The big picture</a></td></tr><tr><td align="right">5 </td><td><a href="First_tutorial.html" class="tocviewlink" data-pltdoc="x">First tutorial</a></td></tr><tr><td align="right">6 </td><td><a href="raco-pollen.html" class="tocviewlink" data-pltdoc="x">Using <span class="stt">raco pollen</span></a></td></tr><tr><td align="right">7 </td><td><a href="File_formats.html" class="tocviewlink" data-pltdoc="x">File formats</a></td></tr><tr><td align="right">8 </td><td><a href="reader.html" class="tocviewlink" data-pltdoc="x">◊ command overview</a></td></tr><tr><td align="right">9 </td><td><a href="Module_reference.html" class="tocviewselflink" data-pltdoc="x">Module reference</a></td></tr><tr><td align="right">10 </td><td><a href="Acknowledgments.html" class="tocviewlink" data-pltdoc="x">Acknowledgments</a></td></tr><tr><td align="right">11 </td><td><a href="License___source_code.html" class="tocviewlink" data-pltdoc="x">License & source code</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">▼</a></td><td>9 </td><td><a href="Module_reference.html" class="tocviewlink" data-pltdoc="x">Module reference</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">9.1 </td><td><a href="Cache.html" class="tocviewlink" data-pltdoc="x">Cache</a></td></tr><tr><td align="right">9.2 </td><td><a href="Decode.html" class="tocviewlink" data-pltdoc="x">Decode</a></td></tr><tr><td align="right">9.3 </td><td><a href="file-types.html" class="tocviewlink" data-pltdoc="x">File</a></td></tr><tr><td align="right">9.4 </td><td><a href="Pagetree.html" class="tocviewlink" data-pltdoc="x">Pagetree</a></td></tr><tr><td align="right">9.5 </td><td><a href="Render.html" class="tocviewlink" data-pltdoc="x">Render</a></td></tr><tr><td align="right">9.6 </td><td><a href="Template.html" class="tocviewlink" data-pltdoc="x">Template</a></td></tr><tr><td align="right">9.7 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Tag</a></td></tr><tr><td align="right">9.8 </td><td><a href="Top.html" class="tocviewlink" data-pltdoc="x">Top</a></td></tr><tr><td align="right">9.9 </td><td><a href="World.html" class="tocviewlink" data-pltdoc="x">World</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28def._%28%28lib._pollen%2Ftag..rkt%29._make-tag-function%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">make-<wbr></wbr>tag-<wbr></wbr>function</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.0.1</span></div><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.0.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.0.1");">top</a></span><span class="navright"> <a href="Template.html" title="backward to "9.6 Template"" data-pltdoc="x">← prev</a> <a href="Module_reference.html" title="up to "9 Module reference"" data-pltdoc="x">up</a> <a href="Top.html" title="forward to "9.8 Top"" data-pltdoc="x">next →</a></span> </div><h4>9.7<tt> </tt><a name="(part._.Tag)"></a><a name="(mod-path._pollen/tag)"></a>Tag</h4><p><table cellspacing="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.0.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen/tag</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">pollen</span></span></td></tr></table></p><p>Convenience functions for working with tags.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._pollen/tag..rkt)._make-tag-function))"></a><span title="Provided from: pollen/tag | Package: pollen"><span class="RktSym"><a href="#%28def._%28%28lib._pollen%2Ftag..rkt%29._make-tag-function%29%29" class="RktValDef RktValLink" data-pltdoc="x">make-tag-function</a></span></span><span class="hspace"> </span><span class="RktVar">id</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.0.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=txexpr&rel=index.html%23%2528def._%2528%2528lib._txexpr%252Fmain..rkt%2529._txexpr%7E3f%2529%2529&version=6.0.1" class="RktValLink Sq" data-pltdoc="x">txexpr?</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">id</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=txexpr&rel=index.html%23%2528def._%2528%2528lib._txexpr%252Fmain..rkt%2529._txexpr-tag%7E3f%2529%2529&version=6.0.1" class="RktValLink Sq" data-pltdoc="x">txexpr-tag?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Make a tag function for <span class="RktVar">id</span>. As arguments, a tag function takes an optional set of X-expression attributes (<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=txexpr&rel=index.html%23%2528def._%2528%2528lib._txexpr%252Fmain..rkt%2529._txexpr-attrs%7E3f%2529%2529&version=6.0.1" class="RktValLink Sq" data-pltdoc="x">txexpr-attrs?</a></span>) followed by X-expression elements (<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=txexpr&rel=index.html%23%2528def._%2528%2528lib._txexpr%252Fmain..rkt%2529._txexpr-elements%7E3f%2529%2529&version=6.0.1" class="RktValLink Sq" data-pltdoc="x">txexpr-elements?</a></span>). From these, the tag function creates a tagged X-expression using <span class="RktVar">id</span> as the tag.</div></p><p><table cellspacing="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.0.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="hspace"> </span><span class="RktSym">pollen/tag</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=reference&rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&version=6.0.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">beaucoup</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._pollen%2Ftag..rkt%29._make-tag-function%29%29" class="RktValLink" data-pltdoc="x">make-tag-function</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">em</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">beaucoup</span><span class="hspace"> </span><span class="RktVal">"Bonjour"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(em "Bonjour")</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">beaucoup</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">id</span><span class="hspace"> </span><span class="RktVal">"greeting"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">"Bonjour"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(em ((id "greeting")) "Bonjour")</span></p></td></tr></table></blockquote></td></tr></table></p><p>Entering attributes this way can be cumbersome. So for convenience, a tag function provides an alternative: any symbol + string pairs at the front of your expression will be interpreted as attributes, if the symbols are followed by a colon. If you leave out the colon, the symbols will be interpreted as part of the content of the tag.</p><p><table cellspacing="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.0.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="hspace"> </span><span class="RktSym">pollen/tag</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=reference&rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&version=6.0.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">beaucoup</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._pollen%2Ftag..rkt%29._make-tag-function%29%29" class="RktValLink" data-pltdoc="x">make-tag-function</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">em</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">beaucoup</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">id:</span><span class="hspace"> </span><span class="RktVal">"greeting"</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">class:</span><span class="hspace"> </span><span class="RktVal">"large"</span><span class="hspace"> </span><span class="RktVal">"Bonjour"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(em ((id "greeting") (class "large")) "Bonjour")</span></p></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="RktCmt">Don</span><span class="RktCmt">'</span><span class="RktCmt">t forget the colons</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">beaucoup</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">id</span><span class="hspace"> </span><span class="RktVal">"greeting"</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">class</span><span class="hspace"> </span><span class="RktVal">"large"</span><span class="hspace"> </span><span class="RktVal">"Bonjour"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(em id "greeting" class "large" "Bonjour")</span></p></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="RktCmt">Don</span><span class="RktCmt">'</span><span class="RktCmt">t forget to provide a value for each attribute</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">beaucoup</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">id:</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">class:</span><span class="hspace"> </span><span class="RktVal">"large"</span><span class="hspace"> </span><span class="RktVal">"Bonjour"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(em id: class: "large" "Bonjour")</span></p></td></tr></table></blockquote></td></tr></table></p><p>Pollen also uses this function to provide the default behavior for undefined tags. See <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.0.1/html/local-redirect/index.html?doc=reference&rel=__top.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._%7E23%7E25top%2529%2529&version=6.0.1" class="RktStxLink Sq" data-pltdoc="x">#%top</a></span>.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.0.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.0.1");">top</a></span><span class="navright"> <a href="Template.html" title="backward to "9.6 Template"" data-pltdoc="x">← prev</a> <a href="Module_reference.html" title="up to "9 Module reference"" data-pltdoc="x">up</a> <a href="Top.html" title="forward to "9.8 Top"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html> |