Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have a similar requirement for a current project, except my 'designers' are more or less end users (people that know their way around html, but it's not their job) which leads to some additional challenges. My implementation is probably too specific for your needs but I'll quickly explain it lest it be useful to anyone else.</p> <p>I wanted to totally avoid any kind of code in the views for the pages they would be designing so I decided to go with a templating system that does something similar to your point #2, but not at runtime. I am also using spark, although it's not for the benefit of the users as they won't be touching anything that looks like code.</p> <p>Basically the users create a full html-only template that has placeholder tags for user controls and partial views. The users then upload the template through an interface that parses it and turns it into a spark view. </p> <p>eg. For a picture gallery, <code>&lt;gallery /&gt;</code> is parsed into something like <code>!{Html.Gallery(Model)}</code> or <code>&lt;use file="Gallery"/&gt;</code>. For a description field, <code>&lt;desc name="Kitchen" /&gt;</code> is parsed into <code>!{Html.Description(Model, x =&gt; x.Descriptions.Kitchen)}</code>. It also checks that "Kitchen" is in fact a property for the object/page that is being templated, or that the Model being passed in for a gallery actually contains a collection of images to avoid runtime errors.</p> <p>Further properties can be specified in the tag to pass additional parameters to the parsed controls. If the control specified requires Javascript, then it is also included in the view. If there are any problems parsing, output is return specifying which placeholder is invalid and why. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload