viewengine

Node js hbs module and engine

丶灬走出姿态 提交于 2019-12-24 11:23:02
问题 I'm new to node js and came across this hbs module and saw it in this part code for example : app.set('view engine', 'html'); app.engine('html', require('hbs').__express); can anyone please explain what is hbs (handlebars - but what does it do)? and why the second line is needed if the first already says that the files will be opened as html Thank you! 回答1: hbs is a express.js wrapper for the handlebars.js javascript template engine . Handlebars.js is a template engine to make writing html

node.js : rendering error with vash

微笑、不失礼 提交于 2019-12-23 16:21:17
问题 I'm getting a rendering error in node.js with vash. I'm really struggling to see what the issue is. Below is the error and the code causing the error. TypeError: Problem while rendering template at line 4, character 2. Original message: object is not a function. Context: 2 | @html.block('body', function(model){ 3 | <p>@model.title </p> > 4 | }); 5 | }); 6 | 7 | at helpers.extend.model (C:\Users\user009\Dropbox\cpp\node_modules\vash\build\vash.js:2213:4) at Object.vash.loadFile (C:\Users

Controlling Razor views programmatically?

你说的曾经没有我的故事 提交于 2019-12-23 03:07:38
问题 Is is possible to programmatically control Razor views? Can I reach the different RenderSection parts or change the Layout definition in code? I'm looking into possibilities to use Razor syntax in the presentation layer of a CMS application. Might Spark be a better choice because of it's (parseable) XML syntax? 回答1: Take a look at http://razorengine.codeplex.com and http://tqcblog.com/2011/01/23/precompiled-razor-for-shared-views-and-mono/ - you can convert razor views to c# code and set the

ASP.NET (MVC) - render page to a file

一个人想着一个人 提交于 2019-12-21 23:01:15
问题 I have to create a bunch of static html files as console / winform job. The current solution uses a string builder. Having used ASP.NET-MVC with strongly typed view pages (System.Web.Mvc.ViewPage) I was wondering if it is possible to leverage these view pages and have them output to a stream or file without building an ASP.NET solution. Essentially I'd like to create the viewpage, pass in the strongly typed object, and render the result. I'm also open to other view engines. If this ends up

How can I create simple view engine like Mustache {{ }} using JavaScript only [closed]

自闭症网瘾萝莉.ら 提交于 2019-12-20 07:56:16
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . How can I create simple view engine like Mustache, so that the word between the {{ }} is replaced by its value, like: <p>hey there {{ codeName }}</p> codeName = 'JavaScript 6' so that it be converted to: <p>hey there JavaScript 6</p> 回答1: I found the below to be proper way to

Why do we use HTML helper in ASP.NET MVC?

你。 提交于 2019-12-18 19:05:35
问题 Are there any good thing, best practice or profit we have after using the HTML helper in an ASP.NET MVC project? When I am trying to use them I found that I lose the speed I have with HTML and many difficulties I have whenever I use an HTML helper. Other [non-techie] persons can't understand what I write using Helper if I want to show them or they want to do something they need to spent more time on, even if they have working knowledge of HTML. If I use an HTML helper I lose the speed. When I

Why do we use HTML helper in ASP.NET MVC?

让人想犯罪 __ 提交于 2019-12-18 19:05:05
问题 Are there any good thing, best practice or profit we have after using the HTML helper in an ASP.NET MVC project? When I am trying to use them I found that I lose the speed I have with HTML and many difficulties I have whenever I use an HTML helper. Other [non-techie] persons can't understand what I write using Helper if I want to show them or they want to do something they need to spent more time on, even if they have working knowledge of HTML. If I use an HTML helper I lose the speed. When I

Razor vs Webforms view engine for new ASP.NET MVC 3 site

隐身守侯 提交于 2019-12-12 08:22:21
问题 Razor is prettier (and is new therefore cool). Webforms is something I am already familiar with. Naturally I would unquestionably go for the new thing to learn - Razor. But I have heard of two disadvantages that worry me: can't easily reuse existing web forms controls - in the rare instance I may need to drag something across... I'll reiterate - 'RARE' I hear it is less efficient at rendering (takes longer than web forms) So what are the advantages of Razor over Webforms view engines when

Literals that precede { in spark view engine

最后都变了- 提交于 2019-12-11 07:30:38
问题 I was going through the spark view engine documentation and found a lot of literals showing up in code for which I couldn’t find any references. For e.g. ! , # , $ , !$ , ... What are these for? What do the combinations mean? When do they come into use? Am I missing any more literals that precede or comes after { 回答1: Also ?{ for conditional output. 回答2: Found one: The syntax $!{expression} can also be used if you want to ensure any null values and NullReferenceException that result from the

ASP.NET MVC Use Controller or View outside of the MVC application context

帅比萌擦擦* 提交于 2019-12-11 05:58:49
问题 Hello i am creating a small webpage that give our users an interface to search in our database. This website must supply 2 webservice functions, Search(string searchString) and GetAccountInfoByInitials(string initials) I would like to use my controllers to do this, but i can not find out how i can get the html out of a ViewResult. I have tryed the following, but the result.ToString() only give me the string "System.Web.Mvc.ViewResult" public class SearchService : ISearchService { private