Are multiline strings possible?

Sep 25, 2014 at 8:53 PM
Togakangaroo wrote:

I would like to use ClearScript to compile handlebarsjs templates. Handlebars templates can be full html documents that as far as I know there's no good way to build up in js alone ( they have to be passed in via an API or grabbed via an ajax download or elment.innerHTML).

Is there a way in ClearScript where I can inject a multiline string containing a document into a variable or am I barking up the wrong tree?

Sure, the host can pass any string to a script function:
// C#
string document = GetOrCreateDocument();
... or store the string as a property in a script object (the global object in this case):
// C#
engine.Script.document = document;
There are no restrictions on string size or contents.

Good luck!
Sep 25, 2014 at 10:19 PM
oooh man. That's awesome.

Another question, does Clearscript not provide the JSON object to stringify?
Sep 26, 2014 at 12:22 PM
Hi again,

The JSON object is a JavaScript built-in. If you're using V8, it should be there by default.

JScript on the other hand implements an older JavaScript standard by default - one that doesn't include JSON. However, it also supports "Standards Mode" in which JSON is implemented. To enable it, pass WindowsScriptEngineFlags.EnableStandardsMode to the JScriptEngine constructor.