Use .cshtml pages in Composite C1 that are not strict XHTML

I need to include some .cshtml / razor pages on the Composite C1 site that do not provide strict XHTML / XML.

ie - any unclosed tags at the moment, for example, prevent the page from loading.

The client requires it; is it possible?

thank

+3


source to share


2 answers


Wrap bad / unsafe markup in a CDATA section. Since the strict XML requirement is primarily needed within the Composite C1 rendering engine and is generally not browser specific, Composite C1 treats CDATA sections as "messy markup" that it won't parse, but just emits raw:

<div>
  <![CDATA[
    Bad & ugly HTML!<br>
  ]]>
</div>

      

It will pass through Composite C1 unhindered and exit as:

<div>
    Bad & ugly HTML!<br>
</div>

      



The above is from http://docs.composite.net/Layout/Writing-XHTML

Here's a simple example with Razor syntax:

<div>
  <![CDATA[
    @{
      string unstructuredMarkup = "Bad & ugly HTML!<br>";
      @Html.Raw(unstructuredMarkup);
    }
  ]]>
</div>

      

+2


source


You can set the ReturnType of your function to a string (by default it is XhtmlDocument). You do this by overriding the ReturnType property like this



@functions
{
   protected override Type FunctionReturnType
   {
      get { return typeof(string); }
   }
}

      

+2


source







All Articles