Generating a plain text file from the CMS

ediego's Avatar

ediego

27 Jul, 2015 12:00 PM

I have an asset that I built for generating a .htaccess file that contains user defined redirects for a site. It works to a certain point, but when the asset gets published to the destination server it has the <system-region name="DEFAULT"> at the top and the closing tag at the bottom. See the attached file.

The asset template only contains the single system-region tag. (template.txt)

and the configuration set settings:
Template
_cascade/templates/common-default
Format
None applied
Publishable
Yes
File Extension
.htaccess
Serialization Type
CSS
Include XML Declaration
No
Default Output
Yes

Any ideas on how I can remove the system-region tags.

  1. 1 Posted by Ryan Griffith on 27 Jul, 2015 12:16 PM

    Ryan Griffith's Avatar

    Hi Emil,

    Because Cascade expects the resulting content to be valid XML, you will need to tweak your setup slightly to accomplish this.

    When you have a a moment, change your Template to the following:

    <!--#cascade-skip--><pass-through><system-region name="DEFAULT"/></pass-through>
    

    And surround your actual htaccess content with #protect-top code sections.

    To summarize, the <pass-through> element within the Template will allow you to work around the "root node" requirement for valid XML, and the #cascade-skip will remove that element on render. The #protect-top will move your content to the very top, resulting in a plain text file being generated.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by ediego on 27 Jul, 2015 12:27 PM

    ediego's Avatar

    that worked perfectly.

    thanks.

  3. 3 Posted by Ryan Griffith on 27 Jul, 2015 12:28 PM

    Ryan Griffith's Avatar

    Thank you for following up, Emil, I am glad to hear that did the trick.

    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!

  4. Ryan Griffith closed this discussion on 27 Jul, 2015 12:28 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