We are in the process of moving our coding standard away from the old includes and towards helpers, functions and partials via the techniques described by Dynamicweb
here https://doc.dynamicweb.com/forum/templates/razor-partial-views-and-helper-functions?PID=1605 .
During this process we have had a few issues, due to how the new include( "template", "namespace" ) function has been implemented.
1) If any typo has been made in "namespace" then everything looks fine in the IDE but an error is thrown on the website. This can get rather annoying when you have
many includes of this type because you have categorized your helper functions into several files. This is off course due to the fact that the IDE assumes that the app_code
folder works as "normal", hoever since Dynamicweb is mvc-like it is actually the regex engine which edits the file before the template engine renderes it.
2) @Include( "template", "namespace" ) does not work, you have to write exactly @Include("template","namespace"). Note the spacing, since this conflicted with our code
style this caused a rather lengthy debugging session when our helpers no longer worked. This happens because the razor function which intellisense sees, and which is a
standard razor function https://antaris.github.io/RazorEngine/references/razorengine-templating-templatebase-1.html, isn't what includes the file. That is done via the
regex engine, with the spacing the regex engine does not catch the include and the razor function is fired which causes an error.
3) Judging by the parsed templates @Include("template","namespace") works by pasting the contents of the file into the tempalte and removing any references to the
namespace. If this is correct then you would encounter issues if you have two helper files which have functions with the same signature.
We are fully aware that this is due to Dynamciweb being mvc-like and not mvc, as Nicolai mentioned in the previous forum post. However we are attempting to
set a coding standard which utilizes Dynamicweb in the best possible manner while taking advantage of intelisense and allowing developers to search for information online.
When Dynamicweb uses a regex engine to overwrite what looks like legitimate razor code, then this causes confusion as to when we are writing code for razor and when
we are writing code for the regex engine. Along the same train of thought it can be problematic to try and translate the razor/mvc information you find online
(the two are usually connected) to dynamicweb mvc-like.
@Dynamicweb Can you tell us a bit about your future plans. Is the plan for you to go forward with mvc-like or can we look forward to real mvc?