title: Call XSLT template and save all output to variable
body: <p>I want to call and template and save the output to a variable. I want to save <em>ALL</em> of the output including HTML markup, but that's not what happens.</p>
  
  <p>For example, take this simple XSLT:</p>
  
  <pre><code>&lt;xsl:call-template name="demonstration"&gt;
  
  &lt;xsl:template name="demonstration"&gt;
      &lt;p&gt;Just a test&lt;/p&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>This simple template will output <code>&lt;p&gt;Just a test&lt;/p&gt;</code> to the HTML page. If I view the page source, I see that (of course). Now take this example using the same template, but instead of just outputting to HTML I want to save the output to a variable:</p>
  
  <pre><code>&lt;xsl:variable name="test"&gt;
      &lt;xsl:call-template name="demonstration"&gt;
  &lt;/xsl:variable&gt;
  &lt;xsl:value-of select="$test"/&gt;
  
  
  &lt;xsl:template name="demonstration"&gt;
      &lt;p&gt;Just a test&lt;/p&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Viewing the variable shows that the only output now is <code>Just a test</code>.</p>
  
  <p>Where did the HTML markup go? I'd like to be able to save the output of a call-template to a variable, but I need the HTML markup too.</p>
  
  <p>Is there a way of avoiding the loss of HTML tags when calling a template like this? Is there a different way of writing my template? Maybe a setting I'm missing? I've tried <code>disable-escape-encoding</code>, but that makes no difference (in Safari at least).</p>
  
  <p>I prefer to use the template for both needs: I'd like to be able to just call it and have the output in an HTML page for viewing. I'd also like to be able to wrap the call in a variable, but it's important that both call methods including all of the HTML tags/markup as specificed in the template.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I've tried both of the posted answers so far, but <code>copy-of</code> gives me the same result as <code>value-of</code>. Actually, I'm not using <code>value-of</code>, I was only showing how to duplicate the problem. Here is a more thorough explanation of what I'm trying to do.</p>
  
  <p>Have a stylesheet that is used to transform a rather large XML received from a REST response. The stylesheet has its output method set for html.</p>
  
  <p>One of the templates in this stylesheet does a lot of decision-making on how to display as many as 4 rows of data in a table. There are 2 columns, one is for a label, the other is for data.</p>
  
  <p>The decision-making that's done includes what the text of the label is and what class - sometimes the label is green, sometimes its red, etc. The data column can contain text and/or numbers. Some of the text might be bold, some might be colorized. There are a bunch of prerequisites that determine these attributes.</p>
  
  <p>If I were displaying a details of a single item, I'd be done with this template, but one of these items can have a multitude of attributes chosen. For example, there might be a size and a color. Depending on which size or color a user chooses, the price can be different, the particular item might be out of stock, if it has a different price then it will have a different savings to the user. Different items might have free shipping, or might be available for preorder only. There are LOTS of attributes.</p>
  
  <p>And so I have a template that anylizes all of these prerequisites and constructs a <code>&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;</code> filled with firly simple text and data derived by some not-so-simple logic.</p>
  
  <p>I've modularized this template so that I can call it for any one of the items. It's paramertized so I can specify the label text, data, class, and a couple of other things.</p>
  
  <p>When the web page loads, the default/main item is displayed along with general info - like the range of prices and a range of savings, etc.</p>
  
  <p>But when a user selects a color or size, these table rows need to be updated with the correct data. I've already processed the data from the XML and it would be very costly to make another server request, so what I have done is created a JSON string array containing all of the data for all of the different kinds of items. I save this JSON in the value attribute of a hidden input control. There's other ways of doing it, yes, but this works and it seems manageable to me.</p>
  
  <p>Since the logic to create these table rows is in the stylesheet on the server, I perform all this logic on all items and then pass the calculated strings to the client. Here is an example of what this looks like:</p>
  
  <pre><code>&lt;input id="hfData" type="hidden" value="[
  {"ProductID": "00001", "Color": "Beige", "Size": "14"},
  {"ProductID": "00002", "Color": "Black", "Size": "14"},
  {"ProductID": "00003", "Color": "Blue", "Size": "10"},
  {"ProductID": "00004", "Color": "Pink", "Size": "10"},
  {"ProductID": "00005", "Color": "Yellow", "Size": "10"}
  ]"
  /&gt;
  </code></pre>
  
  <p>I then have a small JQuery script that is triggered any time the user changes a dropdownlist selection, or changes an attribute. The script parses the above JSON and determines what the currently configured ProductID is.</p>
  
  <p>Note: Since the value attribute of the input control would not be valid if I had double quotes scattered through it like this, they are actually all <code>&amp;quot;</code>. I'm showing double quotes here to make it easy to look at.</p>
  
  <p>Once the ProductID is determined, the page gets updated with lots of different details as described earlier in this edit. These details come from yet another JSON object I've created - again, since all of the product details are known in the XSLT Stylesheet, that is where I am creating the JSON string array. </p>
  
  <pre><code>&lt;input id="hfDetails" type="hidden" value="[
  {"ProductID": "00001", "ListPrice": "&lt;tr class="collapsed"&gt;&lt;td class="datalabel"&gt;List Price:&lt;/td&gt;&lt;td class="datainfo"&gt;&lt;/td&gt;&lt;/tr&gt;", "YourPrice": "&lt;tr&gt;&lt;td class="datalabel"&gt;Price:&lt;/td&gt;&lt;td class="datainfo"&gt;$23.99 &amp; is elegible for &lt;span class="freeshipping"&gt;FREE&lt;/span&gt; shipping &lt;a href="#"&gt;Details&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;"},
  
  ... etc, etc, etc ...
  
  ]"
  /&gt;
  </code></pre>
  
  <p>As you can see, the hidden input just above has a value attribute containing a JSON object which contains HTML markup. I've seen this work, but in order to get JSON to work correctly I have to escape all of the tags. Ampersands have to be <code>&amp;amp;</code>, then there's <code>&amp;lt;</code>, <code>&amp;gt;</code> and also escaping all quotes with a backslash. I've coded it all that way and it works - albeit nasty to look at, it works and it prevents me from having to make round trips to the server - it prevents me from putting all the logic to create these strings on the client side.</p>
  
  <p>None of this has anything to do with the problem I'm having, but I'm hoping to get rid of all the comments from JSON and XSL/XML professors who challenge me for having JSON and XSLT (or HTML) in a single sentence...</p>
  
  <p>Now, I hope I can show (very simply) the precise problem I am having. To start, it has really VERY LITTLE to do with JSON. It has virtually nothing to do with using <code>xsl:value-of</code> over <code>xsl:copy-of</code>. </p>
  
  <p>Here is where I create a hidden input field with the value attribute containing a JSON string:</p>
  
  <pre><code>&lt;input&gt;
    &lt;xsl:attribute name="id"&gt;
      &lt;xsl:value-of select="$id"/&gt;
    &lt;/xsl:attribute&gt;
    &lt;xsl:attribute name="type"&gt;
      &lt;xsl:text&gt;hidden&lt;/xsl:text&gt;
    &lt;/xsl:attribute&gt;
    &lt;xsl:attribute name="runat"&gt;
      &lt;xsl:text&gt;server&lt;/xsl:text&gt;
    &lt;/xsl:attribute&gt;
    &lt;xsl:attribute name="value"&gt;
      &lt;xsl:text&gt;[&lt;/xsl:text&gt;
  
      &lt;xsl:for-each select="Items/Item"&gt;
            &lt;xsl:call-template name="JSONItemDetails"&gt;
              &lt;xsl:with-param name="offerNode" select="Offers"/&gt;
              &lt;xsl:with-param name="lastitem" select="position() = last()"/&gt;
            &lt;/xsl:call-template&gt;
      &lt;/xsl:for-each&gt;
  
      &lt;xsl:text&gt;]&lt;/xsl:text&gt;
    &lt;/xsl:attribute&gt;
  &lt;/input&gt;
  
  
  &lt;xsl:template name="JSONItemDetails"&gt;
      &lt;xsl:param name="offerNode" select="."/&gt;
      &lt;xsl:param name="attributesNode" select="ItemAttributes"/&gt;
      &lt;xsl:param name="listprice" select="0"/&gt;
      &lt;xsl:param name="lastitem" select="false()"/&gt;
  
      &lt;!-- Product ID --&gt;
      &lt;xsl:text&gt;{&lt;/xsl:text&gt;
      &lt;xsl:text&gt;&amp;quot;ProductID&amp;quot;: &lt;/xsl:text&gt;
      &lt;xsl:text&gt;&amp;quot;&lt;/xsl:text&gt;
      &lt;xsl:value-of select="./ProductID"/&gt;
      &lt;xsl:text&gt;&amp;quot;,&lt;/xsl:text&gt;
  
      &lt;xsl:for-each select="msxml:node-set($offerNode)"&gt;
  
          &lt;!-- Title --&gt;
          &lt;xsl:text&gt;&amp;quot;Title&amp;quot;: &lt;/xsl:text&gt;
          &lt;xsl:text&gt;&amp;quot;&lt;/xsl:text&gt;
          &lt;xsl:call-template name="escapeQuote"&gt;
              &lt;xsl:with-param name="pText"&gt;
              &lt;xsl:call-template name="title"&gt;
                  &lt;xsl:with-param name="node" select="$attributesNode" /&gt;
              &lt;/xsl:call-template&gt;
              &lt;/xsl:with-param&gt;
          &lt;/xsl:call-template&gt;
          &lt;xsl:text&gt;&amp;quot;,&lt;/xsl:text&gt;
  
          &lt;!-- List Price --&gt;
          &lt;xsl:text&gt;&amp;quot;ListPrice&amp;quot;: &lt;/xsl:text&gt;
          &lt;xsl:text&gt;&amp;quot;&lt;/xsl:text&gt;
          &lt;xsl:call-template name="escapeQuote"&gt;
              &lt;xsl:with-param name="pText"&gt;
              &lt;xsl:call-template name="DataTableRow"&gt;
                  &lt;xsl:with-param name="label" select="'List Price:'" /&gt;
                  &lt;xsl:with-param name="data" select="./Price/FormattedPrice" /&gt;
                  &lt;xsl:with-param name="dataid" select="'listprice'" /&gt;
              &lt;/xsl:call-template&gt;
              &lt;/xsl:with-param&gt;
          &lt;/xsl:call-template&gt;
          &lt;xsl:text&gt;&amp;quot;&lt;/xsl:text&gt;
  
      &lt;/xsl:for-each&gt;
  
      &lt;xsl:text&gt;}&lt;/xsl:text&gt;
      &lt;xsl:if test="$lastitem != true()"&gt;
          &lt;xsl:text&gt;,&lt;/xsl:text&gt;
      &lt;/xsl:if&gt;
  </code></pre>
  
  <p></p>
  
  <p>The DataTableRow template does a lot of things and which mostly provide consistency, but also clean up all the stray HTML tags used to create rows and columns. Here is that template.</p>
  
  <pre><code>&lt;xsl:template name="DataTableRow"&gt;
      &lt;xsl:param name="label" select="''"/&gt;
      &lt;xsl:param name="data" select="''"/&gt;
      &lt;xsl:param name="dataid" select="''"/&gt;
      &lt;xsl:param name="concat" select="''"/&gt;
      &lt;xsl:param name="class" select="''"/&gt;
  
      &lt;tr&gt;
          &lt;xsl:choose&gt;
          &lt;xsl:when test="$data = not(string(.))"&gt;
            &lt;xsl:attribute name="style"&gt;
              &lt;xsl:text&gt;display:none&lt;/xsl:text&gt;
            &lt;/xsl:attribute&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt;
             &lt;xsl:attribute name="style"&gt;
             &lt;xsl:text&gt;display:block&lt;/xsl:text&gt;
          &lt;/xsl:attribute&gt;
          &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
  
          &lt;!-- Label Column --&gt;
          &lt;td&gt;
              &lt;div&gt;
                  &lt;xsl:choose&gt;
                  &lt;xsl:when test="$class = 'bigmaroon'"&gt;
                      &lt;xsl:attribute name="class"&gt;
                          &lt;xsl:text&gt;datalabel maroon&lt;/xsl:text&gt;
                      &lt;/xsl:attribute&gt;
                 &lt;/xsl:when&gt;
                 &lt;xsl:otherwise&gt;
                      &lt;xsl:attribute name="class"&gt;
                         &lt;xsl:text&gt;datalabel&lt;/xsl:text&gt;
                      &lt;/xsl:attribute&gt;
                 &lt;/xsl:otherwise&gt;
                 &lt;/xsl:choose&gt;
                 &lt;xsl:value-of select="$label"/&gt;
             &lt;/div&gt;
          &lt;/td&gt;
  
          &lt;!-- Data Column --&gt;
          &lt;td class="datainfo"&gt;
              &lt;xsl:attribute name="id"&gt;
                  &lt;xsl:value-of select="$dataid"/&gt;
              &lt;/xsl:attribute&gt;
  
              &lt;xsl:choose&gt;
              &lt;xsl:when test="$class = 'strike'"&gt;
                  &lt;strike&gt;
                      &lt;xsl:value-of select="$data" /&gt;
                  &lt;/strike&gt;
                  &lt;xsl:value-of select="$concat"/&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:when test="$class = 'maroon'"&gt;
                  &lt;span class="maroon"&gt;
                      &lt;xsl:value-of select="$data" /&gt;
                  &lt;/span&gt;
                  &lt;xsl:value-of select="$concat"/&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:when test="$class = 'bigmaroon'"&gt;
                  &lt;span class="bigmaroon"&gt;
                      &lt;xsl:value-of select="$data" /&gt;
                  &lt;/span&gt;
                  &lt;xsl:value-of select="$concat"/&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="$data" /&gt;
                  &lt;xsl:value-of select="$concat" /&gt;
              &lt;/xsl:otherwise&gt;
              &lt;/xsl:choose&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  </code></pre>
  
  <p></p>
  
  <p>The DataTableRow template has a bit of logic that would be messy to do everytime I needed to write one of these rows. First off, All of these rows have to exist in the HTML. If there is no data, then they are set with a style of <code>display:none</code>. This is important since I won't be able to fill them in with data from my JQuery script unless there is a valid selector... </p>
  
  <p>Problem is, after all of this, DataTableRow works just fine when it is called directly like this:</p>
  
  <pre><code>&lt;xsl:call-template name="DataTableRow"/&gt;
  </code></pre>
  
  <p>In the above call, the HTML tags are all output to my web page. They look fine, their classes and styles are correct. I can call it like this from anywhere in my template and it works just fine. I'm sure there is a bug here or there, and I might see the light on a better/more efficient way of coding this, but it basically works and works well for HTML.</p>
  
  <p>THE PROBLEM: I am unable to get any of the HTML tags when I build my hidden input fields above. The only value that gets stored in my JSON strings are the innerhtml. DataTableRow is called from JSONItemDetails template and instead of getting a result of:</p>
  
  <pre><code>&lt;tr&gt;&lt;td&gt;Some Label&lt;/td&gt;&lt;td&gt;Some Data&lt;/td&gt;&lt;/tr&gt;
  </code></pre>
  
  <p>I get a result of</p>
  
  <pre><code>Some LabelSome Data
  </code></pre>
  
  <p>This was an awfult lot of information to ask such a simple question, but I've been getting responses that seem to hint I'm not doing things right if I'm dealing with JSON within XSLT/HTML. </p>
  
  <p>Can anyone help with my problem? Why are the HTML tags being stripped from the output of DataTableRow when I call it in JSONItemDetails to create my JSON string?</p>
  
  <p><strong>EDIT #2:</strong></p>
  
  <p>I've got several things going on with my code that have been causing this problem of HTML tags being stripped. Am finally getting a handle on what's been causing the problem and now I've been trying to figure out how to resolve the issue. Here are additional notes.</p>
  
  <p>Am able to confirm, <code>xsl:value-of</code> is stripping my HTML tags from the output of a template call. <code>xsl:copy-of</code> shows me the tags I expect. This is a big help for me in understanding where the problem is at, but it also allows me to identify other problems.</p>
  
  <ol>
  <li><code>xsl-copy</code> cannot be used to output under the  tag's value= attribute. I understand why, though I'm clueless of how to handle this problem if I proceed in the direction I was going.</li>
  <li>Even if I figure out a solution to #1, I have to figure out how to escape the double quotes in my HTML markup. Ie: A double quote isn't valid within the value= attribute. I understand that an apostrophe would work, but these double quotes are created from using <code>xsl:attribute</code> under certain tags to specify a class or occassional style. I have a template that escapes double quotes with a backslash, but calling it also strips out my HTML tags and I can't see why - so I don't know how to fix it. I'll post the code for this template below.</li>
  </ol>
  
  <p>If I had a workaround for the above 2 problems I could proceed in the direction I've been going, but I'm open to hearing advice on why I shouldn't be mixing data with display in my JSON.</p>
  
  <p>I mix the two because I don't like the idea of putting the display logic in my JQuery script. I'd like my script to remain ignorant of this logic. It's simple in JQuery using these JSON objects to drill down to a ProductID and replace a table row like this:</p>
  
  <pre><code>        var details = $.parseJSON($("#[id*='hfDetails']").val());
  
          var filteredDetails = $.grep(details, function (n) {
              return n.ProductID == ProductID;
          });
  
          if (filteredDetails.length &gt; 0) {
              var product = filteredDetails[0];
  
              $("div#title").html(product.Title);
  
              $("td#listprice").parent().html(product.ListPrice);
              $("td#price").parent().html(product.Price);
              $("td#yousave").parent().html(product.YouSave);
          }
  </code></pre>
  
  <p>If I remove display from my JSON strings as Dimitre is advising, all the sudden I have to put a lot of logic in my jquery script to not only provide <code>&lt;tr&gt;</code> and <code>&lt;td&gt;</code> formatting (classes), but also logic to wrap the actual data, like <code>&lt;strike</code>, <code>&lt;strong&gt;</code>, color specifications and font sizes or even whether a particular table row is a <code>display:block</code> or a <code>display:none</code>. I absolutely do not want to code any of that logic in JQuery script on the client.</p>
  
  <p>It's a very simple <code>xsl:for-each</code> in my XSLT template to create these strings on the server and to stuff the results in my JSON object so that I can use the above script. Admittingly, it's ugly data to look at.</p>
  
  <p>Another note, no matter if I seperate display from data or not, the current XSLT template I use to process my XML will still be needed in the event there is only one item with a single possibility of display. In the event there is only a single product, JSON doesn't come into the picture since there are no controls displayed on the page to change the product's attributes (color, size, etc).</p>
  
  <p>I definitely want to code this "right", so I certainly appreciate hearing from experience. I just don't think anyone can effectively advise me for or against the end result without knowing all of the considerations made that got me there</p>
  
  <p>Here is (was) the template I used to escape double quotes:</p>
  
  <pre><code>&lt;!--
  Escape quotes with \ for JSON strings
  --&gt;
  &lt;xsl:template name="escapeQuote"&gt;
    &lt;xsl:param name="pText" select="."/&gt;
  
    &lt;xsl:if test="string-length($pText) &gt;0"&gt;
      &lt;xsl:copy-of select="substring-before(concat($pText, '&amp;quot;'), '&amp;quot;')"/&gt;
  
      &lt;xsl:if test="contains($pText, '&amp;quot;')"&gt;
        &lt;xsl:text&gt;\"&lt;/xsl:text&gt;
  
        &lt;xsl:call-template name="escapeQuote"&gt;
          &lt;xsl:with-param name="pText" select="substring-after($pText, '&amp;quot;')"/&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:if&gt;
    &lt;/xsl:if&gt;
  
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>This template strips HTML tags from the input string. I call it like this:</p>
  
  <pre><code>&lt;xsl:variable name="output3"&gt;
      &lt;xsl:call-template name="escapeQuote"&gt;
          &lt;xsl:with-param name="pText"&gt;
          &lt;xsl:call-template name="DataTableRow"&gt;
              ... with-params ...
          &lt;/xsl:call-template&gt;
          &lt;/xsl:with-param&gt;
      &lt;/xsl:call-template&gt;
  &lt;/xsl:variable&gt;
  </code></pre>
  
  <p>Immediately doing:</p>
  
  <pre><code>&lt;xsl:copy-of select="$output3"/&gt;
  </code></pre>
  
  <p>Shows that HTML tags no longer exist and therefore, no double quotes exist either. However, doing this reveals all of my HTML tags:</p>
  
  <pre><code>&lt;xsl:variable name="output3"&gt;
      &lt;xsl:call-template name="DataTableRow"&gt;
          ... with-params ...
      &lt;/xsl:call-template&gt;
  &lt;/xsl:variable&gt;
  &lt;xsl:copy-of select="$output3"/&gt;
  </code></pre>
  
  <p>Thanks for reading all of this - and btw, I see other posts where XSL code is formatted nicely and colorized. It's a LOT easier to read, but I can't get it to work with the code I'm posting. Everything is black text and left-justified. I've tried correcting that, but it's not working for me.</p>
  
  <p><strong>EDIT #3:</strong></p>
  
  <p>Dimitre commented that a quote could be used literally in the value attribute of a hidden input field, so I did some experimenting with that in mind. There seems to be a gotcha everywhere I look.</p>
  
  <p><code>&lt;input value='something containing " literally'/&gt;</code></p>
  
  <p>To get my <code>value=</code> contents wrapped by apostrophes instead of double quotes, I tried creating my hidden <code>&lt;input&gt;</code> like this:</p>
  
  <pre><code>&lt;input&gt;
    &lt;xsl:attribute name="id"&gt;
      &lt;xsl:value-of select="$id"/&gt;
    &lt;/xsl:attribute&gt;
    &lt;xsl:attribute name="type"&gt;
      &lt;xsl:text&gt;hidden&lt;/xsl:text&gt;
    &lt;/xsl:attribute&gt;
    &lt;xsl:attribute name="runat"&gt;
      &lt;xsl:text&gt;server&lt;/xsl:text&gt;
    &lt;/xsl:attribute&gt;
    &lt;xsl:text&gt; value='[&lt;/xsl:text&gt;
    &lt;xsl:copy-of select="$output"/&gt;
    &lt;xsl:text&gt;]'&lt;/xsl:text&gt;
  &lt;/input&gt;    
  </code></pre>
  
  <p>This doesn't work because the <code>&lt;input...&gt;</code> tag gets rendered with the <code>value=</code> attribute (and it's contents) AFTER the closing <code>&lt;/input&gt;</code>.</p>
  
  <p>So I removed the <code>xsl:attribute</code> elements and formed it with <code>xsl:text</code>. Unfortunately, using a <code>&lt;</code> inside a <code>xsl:text</code> isn't valid and generates an error. So I changed the <code>&lt;</code> to <code>&amp;lt;</code> as well as the corresponding <code>&gt;</code>. This didn't generate any errors, but causes the entire <code>&lt;input&gt;</code> and its contents to be displayed as a string when the page is rendered. (I'm viewing the page in Firefox).</p>
  
  <p>I haven't tried coding this with CDATA because I'm pretty sure that's not going to work either and I'll get the same results as the latter - everything being displayed as a string.</p>
  
  <p><em>shrug</em></p>
  
  <p><strong>EDIT #4:</strong></p>
  
  <p>OJay recommended dropping the idea of putting my JSON in the value= attribute of a hidden field. I've considered this all along, but wasn't sure how much I'd have to change my code. When he showed examples of how little I'd have to change, I decided to go for it.</p>
  
  <p>Unfortunately, there's another gotcha.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  var hfDetails = [{ProductID: '000001',Title: '&lt;h3&gt;American Apparel Sheer Jersey Chemise X-Small-Asphalt&lt;/h3&gt;',Condition: 'New',ListPrice: '&lt;tr style="display:block"&gt;
      &lt;td&gt;
        &lt;div class="datalabel"&gt;0List Price:&lt;/div&gt;
      &lt;/td&gt;
      &lt;td class="datainfo" id="listprice"&gt;$24.99&lt;/td&gt;
    &lt;/tr&gt;',Price: '&lt;tr style="display:block"&gt;
      &lt;td&gt;
        &lt;div class="datalabel maroon"&gt;Sale:&lt;/div&gt;
      &lt;/td&gt;
      &lt;td class="datainfo" id="price"&gt;&lt;span class="bigmaroon"&gt;$15.49&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;',YouSave: '&lt;tr style="display:block"&gt;
      &lt;td&gt;
        &lt;div class="datalabel"&gt;You Save:&lt;/div&gt;
      &lt;/td&gt;
      &lt;td class="datainfo" id="yousave"&gt;&lt;span class="maroon"&gt;$9.50 (38%)&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;'},
  
   ....
  
  ]
  &lt;/script&gt;
  </code></pre>
  
  <p>This is a paste from the rendered web page. I'm getting an error of "Unterminated string literal" and it's pointing to the apostrophe right before the very first <code>&lt;tr&gt;</code> - on the second line.</p>
  
  <p>I'm assuming this is because the string has whitespace spreading it over several lines. The whitespace is as-is from making the call-template. I'm not sure how to disable this whitespacing or if that'll even make the difference. Am going to do some googling on this, but does anyone know if there is a way to turn whitespace off for a call-template?</p>