kirbysayshi / vash

Vash, the 60 billion double-dollar template-maker. Razor syntax, for JavaScript templates
Other
524 stars 60 forks source link

[question] How to use vash.helpers.include #126

Open Jan-H-Hu opened 6 years ago

Jan-H-Hu commented 6 years ago

Hello Together

First of all many thanks for Razor Views under Javascript.

I have a question about vash.helpers.include I'm not quite sure how the method is used. I work with Nodejs 8.x, express 4.18, Typescript and vash 0.12.4.

Now you would like to include a "Partial View" in a page. I heard it from Razor:

@await Html.PartialAsync("PartialName", Data)

I think the method "vash.helpers.include" unfortunately does not work.

Can somebody help me? What's missing?

index.ts

router.get('/', async (req: express.Request, res: express.Response) => {
    try {
        res.render('index', {
            title: 'Index',
            authentication: res.locals,
        });
    } catch (e) {

    }
});

Index.vash

@html.extend('layout', function(model){

    @html.block('content', function(model){

        @vash.helpers.include('test', null);

    })
})

Test.vash (PartialView)

<div class="container">
    <div class="row">
        <div class="col-sm-12">
            <h2>Test</h2>
        </div>
    </div>
</div>

Best Regards

Jan

Edit: Sorry my mistake : => @html.include('Test', null);

kirbysayshi commented 5 years ago

I haven't tested vash with a recent version of express. When you run your code, are you seeing anything odd in your output? Such as [VASHMARK- ? If so, the issue is probably this one: https://github.com/kirbysayshi/vash/issues/35#issuecomment-38408041

Basically, a function must be called to signal to vash that rendering has finished.