I'm rendering Spark
templates in a console application and I'm trying to use RenderPartial
like so:
${Html.RenderPartial("_mypartial.spark", myData)}
but I'm getting this error when compiling the view:
The name 'Html' does not exist in the current context
In the Shared\_global.spark
I have added this imports:
<use namespace="System" />
<use namespace="System.Web.Mvc" />
<use namespace="System.Web.Mvc.Html" />
<use namespace="System.Collections.Generic" />
<use namespace="System.Linq" />
Everything else renders fine otherwise, it's just that Html
is not defined.
It it makes any difference, I'm rendering this with an embedded NancyFX
engine.
I believe the problem isn't within the view itself. I'm not familiar NancyFX engine, but all engines views should be using a base view. The default is in the web.config in the views folder:
Of course you're not using razor, this is simply a comparison where
Html
exists onSystem.Web.Mvc.WebViewPage
. How you configure NancyFX, the configuration needs to define the one that supports theHtmlHelpers
(that either come with MVC or NancyFX, I'm not sure).After taking a look at Gibhub It looks very similar:
And the
NancyRazorViewBase
hasHtmlHelpers
on it so it sounds very much like a configuration issue.