Note that there are some explanatory texts on larger screens.

plurals
  1. POPreprocessor for HTML snippets to JS strings
    primarykey
    data
    text
    <p>In my project I have a number of snippets of HTML within Javascript strings. These need to be formatted as valid JS - no newlines for example. In this single line format it can be tiring to edit the HTML (also there's no syntax highlighting in my editor).</p> <p>I had the idea of keeping these snippets as external files and then loading them in at run time but this adds a lot of network calls. The ideal solution would be some kind of preprocessor which could take a number of HTML snippet files and output a JS file with all the HTML parsed into valid JS strings, with filenames as variable names perhaps.</p> <p>Does anything like this exist? Example: Input:</p> <p>snippet_a.html</p> <pre><code>&lt;div&gt; My HTML here including whitespace... &lt;/div&gt; </code></pre> <p>snippet_b.html</p> <pre><code>&lt;div&gt; More HTML here ... &lt;/div&gt; </code></pre> <p>Output as strings.js file:</p> <pre><code>snippet_a = '&lt;div&gt;My HTML here, whitespace as \n ...&lt;/div&gt;'; snippet_b = '&lt;div&gt;More HTML here ...&lt;/div&gt;'; </code></pre> <p>Even cooler if it can put the string where it's meant to be in a certain file via a token. I am thinking of workflow solutions along the lines of a CSS preprocessor, JS compiler, Textmate bundle similar to 'Persistant Include', ANT script...</p> <p>Templating is the usual way to go, But this ties the JS to a particular HTML file where the template was dumped.</p> <p>IMO something like Textmate persistant include function would be great - this works like a comment you can stick in your HTML file at the place to pull in another file's contents when you hit an 'update' shortcut. Doesn't work for JS or preprocess the contents though.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload