Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sugar syntax for layout and partials #102

Open
sant123 opened this issue Apr 19, 2016 · 5 comments
Open

Sugar syntax for layout and partials #102

sant123 opened this issue Apr 19, 2016 · 5 comments

Comments

@sant123
Copy link

sant123 commented Apr 19, 2016

Hi, as the title says it'd be great to have some sugar syntax to render a layout of a partial view in vash. For example, I'd call a view with res.render and then specify a layout like this:

@{
    Layout = "views/shared/_layout.vash";
}

And the way to import a partial view would be:

@RenderPartial("content")

And from the layout we can do this:

@RenderBody()

Including some sections

@RenderSection("foo")

And the way to specify sections:

@section foo{
   <p>Hello from foo</p>
}

This is how ASP.NET MVC razor syntax does, it'd be great if this is implemented and one suggestion to render content to it.

@sant123
Copy link
Author

sant123 commented May 3, 2016

Alou?

@sant123
Copy link
Author

sant123 commented May 10, 2016

@kirbysayshi are you there?

@bishanshan
Copy link

You should read the vash document first,Layout Helpers has a detailed description

@sant123
Copy link
Author

sant123 commented Nov 18, 2016

Sure @bishanshan, it explains how to use the layout helpers using a sintax regard with jade templates. However, the main idea here is to use layout helpers with Asp.Net style that is explained above. You can notice the way to import templates is different as the docs says.

@emjayess
Copy link

emjayess commented May 9, 2018

I'm interested in this too. Or rather, more generally interested why the tagline for vash says

Razor syntax, for JavaScript templates

But when one gets going with it, one quickly discovers the more jade-like patterns and noted lack of more Razor style directives ?

As an example, I was attempting to approximate a Razor template from an asp*net mvc project that uses @Html.Partial() (among other constructs I didn't find in vash), and wound up with this in my setup:

vash.config.helpersName = 'Html'

/**
 * Facade for Razor's .Partial()
 */
vash.helpers.Partial = function(viewName, viewBag) {
  return this.include( viewName, viewBag )
}

// now I can use @Html.Partial('my/view', myData)

... this is in a tiny expressjs setup, where I am only using express to bootstrap and compile/render my vash templates.

Disclosure: I've used plenty of other templating engines, but both vash and Razor are relatively new to me, so forgive me if this has been covered before/elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants