Note that there are some explanatory texts on larger screens.

plurals
  1. POEffective Custom Tag Parsing with C#
    text
    copied!<p>I'm currently playing around with a CMS idea I've got. It's based on a MonoRail, NHibernate stack. I know there are already a million CMS solutions out there. This is more for my benefit for trying some new stuff out.</p> <p>Anyway, the admin side of things is going well with a plugin architecture in full flow, however I've hit a bit of a road block with the front end template management side of things. </p> <p>What I'm wanting to do is allow developers to write their own custom tags e.g.</p> <pre><code>&lt;cms:news&gt; &lt;h1&gt;&lt;cms:news:title /&gt;&lt;/h1&gt; &lt;p&gt;&lt;cms:news:date /&gt;&lt;/p&gt; &lt;cms:news:story /&gt; &lt;/cms:news&gt; </code></pre> <p>I believe this will give developers a great deal of flexibility. </p> <p>The part I'm struggling with is the parsing of these tags. I could use reflection, however I'm worried that this may be quite intensive for every page. Has anyone else done something like this, that has a better solution?</p> <p>Sorry for the lack of info guys. Here is a bit more info for you.</p> <p>The above code would site in a "page" in the CMS. The complete page markup would simply be a DB record.</p> <p>Once the parser hits there tags it would then need to process them to convert them to content. In the example above the parser would hit the cms:news tag and make a call to a function like this</p> <pre><code>public void news() { // Get all of the news articles from the database } </code></pre> <p>The cms:news:title (or cms:news.title) tag would call a function like this</p> <pre><code>public string newstitle() { // Return the news title for the current news element we are rendering } </code></pre> <p>Hope this makes more sense now</p> <p>Thanks</p> <p>John</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