Are multiline strings possible?

Coordinator
Sep 25, 2014 at 9: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();
engine.Script.processDocument(document);
... 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 11:19 PM
oooh man. That's awesome.

Another question, does Clearscript not provide the JSON object to stringify?
Coordinator
Sep 26, 2014 at 1: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.

Cheers!