I'm buliding an application in ASP.NET MVC and considering backbone.js for the client side interaction etc..
Ideally when the pages are loaded i'd like to have all the existing content pre-rendered on the server side and then any new content rendered by backbone.js on the fly.
Naturally i dont really want to write my templates twice.
I'm considering having most of the application templated using the razor view engine and then using mustache templates for the small areas that need to be shared between server and front end.
My question is, what does the actual technical implementation of this look like?
Can you provide code samples of how you would achieve this?
For example which library would you use to render the template on the server and then would you manually extract the text from the template file and inject it into the javascript?
Backend Synchronization BackboneJS is use with the front-end and back-end systems, allows the synchronization with the backend to provide support to RESTful APIs.
Backbone. js is a model view controller (MVC) Web application framework that provides structure to JavaScript-heavy applications. This is done by supplying models with custom events and key-value binding, views using declarative event handling and collections with a rich application programming interface (API).
React. js is very popular and has a lot of community and 3rd party support. Microsoft's answer for SPA apps is Blazor. Blazor is what I would recommend.
BackboneJS allows developing of applications and the frontend in a much easier way by using JavaScript functions. BackboneJS provides various building blocks such as models, views, events, routers and collections for assembling the client side web applications.
Not so much a technical as a functional answer see my answer here for a functional flow incorporating server- and clientside rendering (using Mustache)
Accessibility and all these JavaScript frameworks
hth,
I am evaluating Razor Client Templates (GitHub) at the moment. It is in version 0.7.0 and seems a bit brittle currently.
It allows you to reference individual partial razor views as JavaScript templates.
As part of a commercial product we will be taking this further to output Handlebars.js compatible templates from our Razor partials.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With