classafFancordion::FancordionSkin
sys::Obj afFancordion::FancordionSkin
Implement to create a skin for specification output. Skins are used by Fancordion Commands to generate the HTML result files.
This class renders bare, but valid, HTML5 markup. Override methods to alter the markup generated.
- a
virtual This a(Uri href, Str text)
Renders a complete
<a>
tag.- addCss
virtual Void addCss(File cssFile, Bool overwrite := false)
Copies the given css file to the output dir and adds the resultant URL to
cssUrls
.- addScript
virtual Void addScript(File scriptFile, Bool overwrite := false)
Copies the given script file to the output dir and adds the resultant URL to
scriptUrls
.- blockQuote
virtual This blockQuote()
Starts a
<blockquote>
tag.- blockQuoteEnd
virtual This blockQuoteEnd()
Ends a
</blockquote>
tag.- body
virtual This body()
Starts a
<body>
tag and renders the breadcrumbs.- bodyEnd
virtual This bodyEnd()
Ends a
</body>
tag.This also calls
footer()
and renders thescriptUrls
as<script>
tags.virtual Uri:Str breadcrumbPaths()
Returns an ordered map of URLs to fixture titles to use for the breadcrumbs.
virtual This breadcrumbs()
Renders the breadcrumbs. Makes a call to
breadcrumbPaths()
- cmdErr
virtual This cmdErr(Str cmdUrl, Str cmdText, Err err)
Called to render a command error.
- cmdFailure
virtual This cmdFailure(Str expected, Obj? actual, Bool escape := true)
Called to render a command failure.
- cmdHook
virtual This cmdHook(Uri cmdUrl, Str cmdText, Obj?[]? data)
Custom commands may use this method as a generic hook into the skin.
By default this method returns an empty string.
- cmdIgnored
virtual This cmdIgnored(Str text)
Called to render an ignored command.
- cmdSuccess
virtual This cmdSuccess(Str text, Bool escape := true)
Called to render a command success.
- code
virtual This code()
Starts a
<code>
tag.- codeEnd
virtual This codeEnd()
Ends a
</code>
tag.- copyFile
virtual Uri copyFile(File srcFile, Uri destUrl, Bool overwrite := false)
Copies the given file to the destination URL - which is relative to the output folder. Returns a URL to the destination file relative to the current fixture file. Use this URL for embedding href's in the fixture HTML. Example:
copyFile(`fan://afFancordion/res/fancordion.css`.get, `etc/fancordion.css`) --> `../../etc/fancordion.css`
If
destUrl
is a dir, then the file is copied into it.- cssUrls
Uri[] cssUrls := Uri[,]
CSS URLs are rendered in the
<head>
element. CSS URLs may be added at any stage of rendering as they are added duringhtmlEnd()
.- em
virtual This em()
Starts an
<em>
tag.- emEnd
virtual This emEnd()
Ends an
</em>
tag.- fixtureCtx
virtual FixtureCtx fixtureCtx()
Returns the context associated with the current fixture.
- fixtureMeta
virtual FixtureMeta fixtureMeta()
Returns meta associated with the current fixture.
virtual This footer()
Renders a footer. This is (usually) called by
bodyEnd()
. By default it just renders a simple link to the Fancordion website.- head
virtual This head()
Starts a <head> tag - this should also render a <title> tag.
- headEnd
virtual This headEnd()
- heading
virtual This heading(Int level, Str title, Str? anchorId)
Starts a heading tag, e.g.
<h1>
- headingEnd
virtual This headingEnd(Int level)
Ends a heading tag, e.g.
</h1>
- html
virtual This html()
Starts a
<html>
tag - this should also render the DOCTYPE.Note that XHTML5 documents require the
xmlns
:<html xmlns="http://www.w3.org/1999/xhtml">
- htmlEnd
virtual This htmlEnd()
Ends a
<html>
tag. This also renders thecssUrls
as link tags into the<head>
.- img
virtual This img(Uri src, Str alt)
Renders a complete
<img>
tag.Note that in HTML5 the
<img>
tag is a Void element and may be self closing.- li
virtual This li()
Starts a
<li>
tag.- liEnd
virtual This liEnd()
Ends a
</li>
tag.- link
Renders a CSS
<link>
tag.Note that in HTML5 the
<link>
tag is a Void element and may be self closing.- ol
virtual This ol(OrderedListStyle style)
Starts an
<ol>
tag. By default the list style is added as a CSS style attribute:<ol style="list-style-type: upper-roman;">
- olEnd
virtual This olEnd()
Ends an
</ol>
tag.- p
virtual This p(Str? admonition)
Starts a
<p>
tag. The admonition is added as a class (lowercase):LEAD: Here I am --> <p class="lead">Here I am</p>
- pEnd
virtual This pEnd()
Ends a
</p>
tag.- pre
virtual This pre()
Starts a
<pre>
tag.- preEnd
virtual This preEnd()
Ends a
</pre>
tag.- render
Renders the contents of the given func into a
Str
without appending it to the skin'srenderBuf
.activeLink := skin.render |->| { write("<div class='active'>") a(`http://fantom.org`, "Fantom") write("</div>") }
- renderAnchor
Str renderAnchor(Uri href, Str text)
Renders and returns an
<a>
anchor.- renderBuf
StrBuf renderBuf := StrBuf.<ctor>()
The
StrBuf
that this Skin renders to.- script
Renders a javascript
<script>
tag.Note that in HTML5 the
<script>
tag is NOT a Void element and therefore MUST not be self colsing.- scriptUrls
Uri[] scriptUrls := Uri[,]
Script URLs are rendered just before the closing
</body>
element. Script URLs may be added at any stage of rendering as they are added duringbodyEnd()
.- section
virtual This section()
Starts a section. By default this returns a
div
with the classexample
:<div class="example">
- sectionEnd
virtual This sectionEnd()
Ends an example section. By default this ends a div:
</div>
- setup
virtual Void setup()
Called before every fixture run. This should reset any state held by the skin, e.g. the
cssUrls
andscriptUrls
.- strong
virtual This strong()
Starts a
<strong>
tag.- strongEnd
virtual This strongEnd()
Ends a
</strong>
tag.- table
virtual This table(Str? cssClass := null)
Starts a
<table>
tag.- tableEnd
virtual This tableEnd()
Ends a
</table>
tag.- td
Returns a
<td>
tag.- tearDown
virtual Void tearDown()
Called after every fixture run. This should reset / cleardown any state held by the skin, e.g. the
cssUrls
andscriptUrls
.- text
Renders the given text. By default the text is XML escaped.
- th
Returns a
<th>
tag.- tr
virtual This tr()
Starts a
<tr>
tag.- trEnd
virtual This trEnd()
Ends a
</tr>
tag.- ul
virtual This ul()
Starts a
<ul>
tag.- ulEnd
virtual This ulEnd()
Ends a
</ul>
tag.- write