simoncropparchived / chevron Goto Github PK
View Code? Open in Web Editor NEWWraps Handlebars to make it usable from .net.
License: Other
Wraps Handlebars to make it usable from .net.
License: Other
Why is not the internal MsieJsEngine
disposed? https://github.com/SimonCropp/Chevron/blob/master/Chevron.IE/Handlebars.cs#L203
I change this
var templateName = viewLocationResult.Name;
to
var templateName = string.Concat(viewLocationResult.Location.Replace("/", string.Empty), viewLocationResult.Name);
Got the exception when I generated some "names" using Guid.NewGuid().ToString("n")
. So essentially;
var handlebars = new Chevron.Handlebars();
handlebars.RegisterTemplate(Guid.NewGuid().ToString("n"), content);
Tried passing "1"
, fails as well.
MsieJavaScriptEngine.JsRuntimeException : Compile error: Expected identifier
From the readme:
V8 will, in theory, run on a non windows platform (I have not done any testing of this).
Unfortunately this isn't the case with ClearScript. ClearScript only works on Windows as it uses C++/CLI which is not cross-platform. There are ways to use V8 from Linux or Mac OS, but you need to use a different JavaScript engine. In ReactJS.NET I'm using a fork of VroomJs with JavaScriptEngineSwitcher. VroomJs does run from Mono as it's got a vanilla C interface.
A lot of handlebars helpers are distributed as collection of helpers in one .js file.
Now in Chevron it is necessary to register each helper separtly.
It would be handier if somewhere a set of files to run after running handlebars.js could be specified to register those helpers.
Hi Simon,
Just had a go at trying to get that sample working.
First problem I think is Views/Index.handlebars and Views/_MyPartial.handlebars are not set with Build Action 'Content' and Copy if newer.
Second problem is when I go to http://localhost:8888 nothing is rendered.. so not sure what is going wrong
Keen to get this working :)
Should probably be updated.
Hi,
I tired Chevron.IE
, Chevron.IE.Merged
and Chevron.Jint
but no success.
Also Added MsieJavaScriptEngine
.
Which assembly is for Approvals
?
Thanks.
What is the recommendation of "life cycle" of e.g. https://github.com/SimonCropp/Chevron/blob/master/Chevron.IE/Handlebars.cs
And what about concurrent use of it, since you seem to only check against existence of e.g. templates in ordinare List<string>
? Hence multiple same calls to engine.Execute
can happen?
Are we supposed to use one instance per call or to handle concurrency in calling code?
Is there anyway to make this work?
[Test]
public void CanUseJArrayValues()
{
var jObject = new JObject {{"County", new JArray {"Kane", "Salt Lake"}}};
string actual;
using (var handleBars = new Handlebars())
{
handleBars.RegisterTemplate("county", "{{County.length}}");
actual = handleBars.Transform("county", jObject);
}
Assert.That(actual, Is.EqualTo("2\r\n"));
}
Ran a simple template, and the engine adds \r\n
at the end.
var template = "<h1>Test {{Tag1}}!</h1><p>Test {{Tag1}}.</p><p>Test {{Tag2}}?</p>";
var model = new {Tag1 = "First", Tag2 = "Second"};
using (var handleBars = new Chevron.Handlebars())
{
handleBars.RegisterTemplate("test", template);
return handleBars.Transform("test", model);
}
Hi,
Was wondering whether you might consider exposing the engine on Handlebars.cs so we could load in other general javascript.
e.g. I want to support date formatting, and would ideally register a helper that depends on moment.js.
Thanks,
Chris
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.