Nancy - Super Simple View Engine: How do I override a MasterPage's title in the view? - nancy

I would like to set the title of each rendered page from the corresponding view. I would also like a default title to be set in my Master page. Here is the super-simple set up I am using.
Master Page
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>NancyFX is Splendid</title>
</head>
<body>
#Section['Content']
</body>
</html>
View
#Master['_Master']
#Section['Content']
<h1>Home</h1>
<p>Hello #Model.UserName</p>
#EndSection
I have tried a few of the more obvious guesses but no joy so far. Can you help?
On a more general note - is there any definitive help for Nancy's SSVE? I have read all the docs available on the site and GitHub but they are sparse. Just a list of all SSVE '#[]' keywords, would save me a lot of time.
Thanks

You can just render it from the model, same as anything else:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello #Model.Name!</title>
</head>
<body>
<h1>Super Simple View Engine</h1>
<p>This text is in the master page, it has access to the model:</p>
<p>Hello #Model.Name!<p>
#Section['Content']
</body>
</html>
As for documentation, most of the tags are documented here: https://github.com/grumpydev/SuperSimpleViewEngine although it's slightly out of date now. It was initially designed purely for internal use, but obviously you are welcome to use it if you want to. The best place to look if you get stuck is the tests, there's samples for all the tags in there.

Related

Angular template view with utf-8 chars doesn't work

I try to use "ngroute" to load html templates.
Everything works fine, but when I try to show words in Hebrew in the "ng-view", I get only question marks instead of the Hebrew chars (???????????).
in the <head> tag I added <meta charset="utf-8">
and if the Hebrew is static in the page it works fine.
but when I use "ngroute" to load it it doesn't.
<head>
<!-- start: Meta -->
<meta charset="utf-8">
<title></title>
<!-- end: Meta -->
<script src="js/angular.min.js"></script>
<script src="js/angular-route.min.js"></script>
<script src="js/controllers.js"></script>
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- end: CSS --></head>
Any idea? Is there anything I should add to the html view page?
I added the <meta meta charset=utf-8> tag to the all the templates html and not just to the <head> and it fixed the problem.
I've solved by resaving the html template file with utf-8 encoding. In Visual Studio, Save As > Save with Encoding... button.
I ran into this issue as well for Danish characters and symbols.
I was missing the charset = utf-8 in /.editorconfig under the angular project!
So it defaulted to Windows-1251.
This worked for all new files and when resaving old ones with wrong encoding.

Angular in an XML Namespace does not auto bootstrap via ng:app

I know that due to backwards compatibility with IE, Angular allows the use of an xmlns and using ng: instead of ng-, however it doesn't appear to be working with all directives in xhtml
<?xml version="1.0"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ng="http://angularjs.org">
<head>
<title>Test</title>
</head>
<body ng:app="MyApp">
<div ng:controller="FooController as foo">
<p>{{foo.text}}</p>
</div>
<script src="angular.min.js" />
<script>
var app = angular.module("MyApp", []);
app.controller("FooController", function () {
this.text = "Hello Angular!";
});
</script>
</body>
</html>
The above will just produce {{foo.text}}, but if I replace ng:app with ng-app (leaving ng:controller the way it is) everything works fine. I really like the consistency of using namespaces, so why doesn't ng:app work?
The ng:app syntax doesn't work due to the following:
The elements contained within the template are always created in the HTML namespace. Whilst this is probably fine for the fast majority of cases if someone ever uses AngularJS with another XML document like SVG this could cause some problems.
References
Directive templates are always created in the HTML namespace
XHTML pages with fail to load in Opera
AngularJS Developer Guide: Internet Explorer Compatibility
Your example works fine. Have a look here: http://plnkr.co/edit/mgUMZe09FSr1aALE6ddd?p=preview
Maybe your angular script is not included properly
<script/> should be <script></script> its not self closing html tag

Broken iron-flex-layout dependency

I have a simplistic page:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="bower_components/iron-flex-layout/classes/iron-flex-layout.html">
</head>
<body class="fullbleed vertical layout" unresolved>
<div>Alpha</div>
<div class="flex">Beta (flex)</div>
<div>Gamma</div>
</body>
</html>
It is very near from there given samples for iron-flex-layout.
But it renders an empty page.
If I add another import, like iron-image, the page is displayed correctly.
It is served by polyserve, and everything is correctly installed otherwise.
Thanks for your help / explanation.
My bad here.
At this point unresolved body attribute is not defined.
Removing it makes it work as expected.
No clue where this attribute is defined, though (but importing an element such as iron-element, as mentioned above, and its dependencies makes it defined)

Writing html code dynamically to an aspx file

I have HTML stored in a Microsoft SQL Server column, and I also have an blank .aspx file called myreport.aspx. My problem now is, when I retrieve the contents of the column from the database, I want to be able to write it to the empty myreport.aspx file and use Response.Redirect() to call the myreport.aspx and display it.
The contents of the column looks like this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h1>Welcome Aboard!</h1>
</body>
</html>
And also replace the contents with a new one whenever the page is being called.
I need help, thank you in advance, seniors!

VML v:shape , V:roundrect elements ain`t displayed correctly in IE6, IE7 in strict mode

Does anybody can provide an answer to such issue? I`m trying to put some vector graphics into HTML. Actually it is not necessary in mine case, so I probably would resort to simple image for now, but I as encountered a problem, I couldn't resolve, it's became very interesting and relevant to the future to define what is going wrong. VML is absolutely new to me, by the way.
I tried to insert several vml-elements into a page, and some of them worked perfectly (in IE6, IE7) namely "oval", "rect". But when I've attempted to insert a shape or roundrect everything went wrong.
Actual question is: is there satisfactory VML support in IE6, IE7 or what I'm doing wrong? But as far as I'd examined my code everything is right in it. Below I'll put a sample, so everyone could test this in IE-browser:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>sample</title>
<style>
v\:* { behavior: url(#default#VML); display:inline-block}
#div1 {
width:400px;
height:400px;
background-color:#e4fe56;
}
</style>
</head>
<body>
<div id="div1">
<v:shape style='width:100px;height:100px' fillcolor="red" path="m 0,0 l 30,0,30,30 xe" />
<v:rect style='width:100pt;height:75pt' fillcolor="blue" strokecolor="red" strokeweight="3.5pt"/>
<v:roundrect style='width:100pt;height:75pt" arcsize="0.3" fillcolor="yellow" strokecolor="red" strokeweight="2pt"/>
</div>
</body>
</html>
Additionally I found that it happens only in strict mode. When DOCTYPE removed or with other conditions when IE works in quirks mode everything works well.
You have mismatched quotes on your style attribute
<v:roundrect style='width:100pt;height:75pt"
You have whitespace in your doctype:
/xhtml1 /

Resources