Mikkel Løkke
Mikkel Løkke

Reputation: 3749

Getting [ERR!] as output when trying to use the Nancy SuperSimpleViewEngine to render partials

The example I'm using is literally the one from their example page here: https://github.com/NancyFx/Nancy/wiki/The-Super-Simple-View-Engine

So I have my files set up with index.sshtml and master.sshtml (copy/pasted verbatim from the example) in the root, and serving up the result with:

Get["/"] = result => View["index.sshtml"];

When I then go to visit localhost in my browser I get a text simply saying "[ERR!]", instead of the "This is content on the index page" which I had expected.

What am I doing wrong? Is there something I have to explicitly do to enable the Master/Section functionality of the SSVE?

Edit: Views:

master.sshtml

<html>
<body>
@Section['Content'];
</body>
</html>

index.shtml

@Master['master.sshtml']

@Section['Content']
   This is content on the index page
@EndSection

File structure:

+ Debug
|---ConsoleApplication1.exe
|---index.sshtml
|---master.sshtml
|---(rest of files Visual Studio outputs)

I'm pretty sure this is the simplest example that could possibly work, and for some reason, it doesn't. There are no (uncaught) exceptions thrown, not output in the debug window, and no other indications that something has gone awry, except for the [ERR!] being printed. It is the only content being printed, so I'm assuming it's something in the "Master" block that is failing...

Upvotes: 4

Views: 1327

Answers (2)

Pedram GANJEH HADIDI
Pedram GANJEH HADIDI

Reputation: 49

In my case I had to:

  1. Open the sshtml file in another text-editor, change the encoding to ``UTF-8 no BOM``` then
  2. Remove the whitespace at first position "@Master['MasterPage']" (perhaps it was the UTF8-BOM?)
  3. Save the file.
  4. Go to Visual Studio, a dialog will notify you about the "external changes", click Reload all and everything should be good.

Upvotes: 0

leojh
leojh

Reputation: 7712

In case someone else sees this, make sure that all .sshtml files are marked as 'Copy to Output Directory" : 'Copy Always' under File Properties

Upvotes: 4

Related Questions