南希-超级简单视图引擎:如何在视图中覆盖母版页的标题? [英] Nancy - Super Simple View Engine: How do I override a MasterPage's title in the view?

查看:65
本文介绍了南希-超级简单视图引擎:如何在视图中覆盖母版页的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从相应的视图设置每个渲染页面的 title .我还希望在母版"页面中设置默认标题.这是我正在使用的超简单设置.

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.

母版页

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>NancyFX is Splendid</title>
</head>
<body>
    @Section['Content']
</body>
</html>

查看

@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?

更笼统地说-南希的SSVE是否有明确的帮助?我已经阅读了该站点和GitHub上所有可用的文档,但是它们很少.仅列出所有SSVE'@ []'关键字即可为我节省很多时间.

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.

谢谢

推荐答案

您可以从模型中进行渲染,就像其他任何东西一样:

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>

至于文档,大多数标签都记录在这里: https://github.com/grumpydev/SuperSimpleViewEngine ,虽然现在有点过时了.它最初只是为内部使用而设计的,但是显然,如果您愿意的话,也欢迎您使用它.最好看一下是否卡住的地方就是测试,里面有所有标签的样本.

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.

这篇关于南希-超级简单视图引擎:如何在视图中覆盖母版页的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆