I need to prevent Cascade from adding a slash to my code.

webadmin's Avatar

webadmin

05 Jun, 2015 03:42 PM

I have this line of code in one of my templates:

<h2><a href="/{{url}}">{{title}}</a></h2>

I need to remove that forward slash in front of {{url}}. I've removed it from the published code and it's fixing the problem I'm having. But whenever I try to take it out of the template, it adds it right back in. How do I keep it from doing this?

  1. 1 Posted by Ryan Griffith on 05 Jun, 2015 04:26 PM

    Ryan Griffith's Avatar

    Hi,

    To confirm, is this code from a templating library? When you have a moment, can you describe your setup a bit so I can try to reproduce this behavior locally? For instance, is this a Template asset, an XML/XHTML Block, or a template file you are maintaining within Cascade.

    Also, what version of Cascade are you experiencing this behavior in?

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by webadmin on 05 Jun, 2015 04:34 PM

    webadmin's Avatar

    I assume by template asset you mean a file that is designated as a template in Cascade, right? If so, yes, it's a template asset.

    The version is: 7.12.5 - ac31f

  3. 3 Posted by Ryan Griffith on 05 Jun, 2015 06:19 PM

    Ryan Griffith's Avatar

    Thank you for following up to confirm.

    When you have a moment, please attach or paste the contents of the Template so I can do some local testing.

    Please let me know if you have any questions.

    Thanks!

  4. 4 Posted by webadmin on 08 Jun, 2015 01:49 PM

    webadmin's Avatar

    The template is attached. The line in question is line 162.

  5. 5 Posted by Ryan Griffith on 08 Jun, 2015 02:13 PM

    Ryan Griffith's Avatar

    Thank you for providing your Template code to test with.

    I was able to reproduce the same behavior and I believe the issue is coming from either the XML validation and cleanup routine that Templates undergo upon submission to ensure valid XML or link rewriting.

    There are a couple of possible solutions that should do the trick:

    • Wrap the contents of your <script> tags with CDATA protect code sections. For example:
      <script id="event-template" type="text/x-handlebars-template"><![CDATA[#protect
      <div id="calendarSpacer" ></div>
      <div id="calendarEvent">
          <div id="dateBox">
              <span id="calendarMonth">{{start_date_MMM}}</span>
              <span id="calendarDay">{{start_date_D}}</span>
          </div>
          <div id="text-box">
              <h2><a href="{{url}}">{{title}}</a></h2>
              <p>{{description}}</p>
              <span id="time">{{time_duration_text}}</span>
          </div>
      </div>
      <div id="calendarSpacer" ></div>
      #protect]]></script>
      
    • Move these <script> tags into an XML Block(s), which don't undergo the same cleanup/rewriting routines as Templates

    Please let me know if you have any questions.

    Thanks!

  6. 6 Posted by webadmin on 08 Jun, 2015 02:20 PM

    webadmin's Avatar

    I used the #protect tags, and that did it. Thanks!

  7. 7 Posted by Ryan Griffith on 08 Jun, 2015 02:25 PM

    Ryan Griffith's Avatar

    Thank you for following up to confirm the protect code sections did the trick. I figured that solution would be the best route since it required no changes to your existing setup.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  8. Ryan Griffith closed this discussion on 08 Jun, 2015 02:25 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac