Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Spark View Engine HTML encoding?

Even with the following in spark section of web.config:

<pages automaticEncoding="false">

Things between ${...} Still get passed through H(...), which HTML encodes it.

How change this or should I just fall back to !{...}?

like image 515
Norbert B. Avatar asked Dec 22 '09 12:12

Norbert B.


1 Answers

You can change Spark's default using its configuration, though I would recommend you use ${} when you want encoded HTML and !{} when you don't.

Spark can be configured from either Web.config or using a SparkSettings instance.


In Web.config, under your <spark> configuration, add:

<pages automaticEncoding="false">

You'll want to make sure you only have the one <pages/> element. I'm unsure if Spark's processor will raise an error if you have multiple.


Using SparkSettings, add:

SparkSettings settings = new SparkSettings()
    .SetAutomaticEncoding(false);

If you have these settings and still get automatic encoding, set a break-point at the point where you instantiate your SparkViewFactory (or use Console.WriteLine() or your logging framework) and have a look at:

mySparkViewFactory.Settings.AutomaticEncoding
like image 55
Tom Mayfield Avatar answered Jan 04 '23 14:01

Tom Mayfield