milkshakesoftware / razorjs Goto Github PK
View Code? Open in Web Editor NEWCompile ASP.NET MVC Razor views to JavaScript templates
Compile ASP.NET MVC Razor views to JavaScript templates
In situations where a razor view cannot compile to JavaScript it could be possible to have a Controller on the server that can be called to render the view.
When called on the client, use the model passed to the template function but call the server from the template function instead of relying on the normal rendering.
Write readme with a brief explanation + a few wiki pages documenting usage and supported features.
Support for inline Razor helpers, such as:
@helper ProductImage(ProductViewModel product) {
<img src="@product.ImageUrl" />
}
This requires a JavaScript function (the helper) to be registered at the top of the template function, right after the _tmpl
array so that it can access it.
Since helpers usually appear at the bottom, the stock TextWriter
passed around should be wrapped in a new class that takes input to a specific section. That way, at the end of the template you can easily add content that will go to the helpers section.
var tmpl = function(Model) {
var _tmpl = [];
var ProductImage = function (product) {
_tmpl.push('<img src=\"');
_tmpl.push(product.ImageUrl);
_tmpl.push(' />');
};
_tmpl.push('More of the template');
ProductImage(item);
_tmpl.push('The rest of the template');
};
Add a new Bundle
implementation, like ScriptBundle
, only this one includes a RazorJS template.
Support for bundling and minification on the same level as ScriptBundle
is required.
Loop through a collection, should use the array client-side and run a simple foreach
or for
loop on the client.
To include a template on a page, an HttpHandler
can be used to compile and return the result as a piece of JavaScript that also registers the template function under a specifed name.
When adding the script include to the page, the following URL parameters can be specified:
razorjs.templates.login
HttpHandler
must support caching.
The core RazorJS compiler, compiles a Razor view into a JavaScript function that will render HTML by passing in an object that represents the view model.
Core compiler class, should accept a string (the Razor template), and return a string (the JavaScript template function).
Support for strongly typed models in Razor views, to get the full dev experience.
Model- and using declarations at the top of a view should be removed when compiling to JavaScript.
Control statements, such as if, else if and else should be supported. It is OK to support only validation against simple boolean properties, or JS compatible statements.
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.