sitefox.html
Functions for wrangling HTML and rendering Reagent components into selectors.
$
($ element selector)Shorthand for CSS style querySelector on parsed HTML element such as the document returned by the parse function or a sub-element.
$$
($$ element selector)Shorthand for CSS style querySelectorAll on parsed HTML element such as the document returned by the parse function or a sub-element.
direct-to-template
(direct-to-template res template & selector-component-pairs)Render selector component Reagent pairs into the HTML template string and use the express res to send the resulting HTML to the client.
parse
(parse html-string)Shorthand for node-html-parser’s parse function. Returns a dom-like document object (HTMLElement) that can be manipulated as in the browser.
render-anything
(render-anything source & args)Render anything to HTML. If source is a Reagent form, render-to-static-markup is used. If source is a jsdom HTMLElement or other type of object .toString is used. If source is a fn it will be called with any args that were passed. If source is already a string it is passed through with no change.
render-into
(render-into html-string selector reagent-forms)Render a Reagent component into the chosen element of an HTML document.
html-stringis the HTML document to be modified.selectoris a CSS-style selector such as#appormain.reagent-formsis a valid Reagent component.
select-apply
(select-apply template & selector-application-pairs)Parse template if it is a string and then run each of selector-applications on it. If it is already a document-like object it won’t be parsed first. The selector-applications should each be an array like: [selector document-method-name ...arguments]. For each one the selector will be run and then the method run on the result, with arguments passed to the method. The special ‘method’ setHTML expects a Reagent form which will be rendered and innerHTML will be set to the result.