Output XML as is


#1

I am trying to output XML as is. I tried {{ .RawContent }} in single.html but the output is escaped (e.g. “<” becomes “<” ). Any idea how I can output content “as is”?

The content file looks something like the following:

---
title: test2
---
<?xml version="1.0" encoding="UTF-8"?>
<definitions ...>
  ...
</definitions>

Goal / background: I want to attach a custom widget to Netlify CMS to allow users to view/edit xml-based diagrams. I need “title” in front matter, otherwise the CMS would show a list of pages with no name. So I can’t put them in static/ folder.


#2

I wouldn’t struggle with front matter and content: that is all about processing Markdown, so you’re up against that.

Instead, how about using a shortcode wrapped around readFile? That will generate what you want, and you can reference static.

Have you seen page bundles? I am pretty sure you could just dump all your XML files in a directory and have a list generated for ya.


#3

I worked around the problem by putting everything in frontmatter. So fixed…