GithubHelp home page GithubHelp logo

razorjs's People

Contributors

martinnormark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

razorjs's Issues

Render on server fallback

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.

Inline helpers

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.

Example of the JavaScript template function

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');

};

Support ASP.NET 4.5 bundling

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.

foreach loop support

Loop through a collection, should use the array client-side and run a simple foreach or for loop on the client.

HttpHandler for including templates

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:

  • Controller name
  • View name
  • Area name (optional)
  • Template function name (namespaced e.g. razorjs.templates.login

HttpHandler must support caching.

RazorJS compiler

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).

Strongly typed models

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

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.