Click or drag to resize
HelpersScriptsRender Method
Renders script tags for the specified paths.

Namespace: HandlebarsDotNet.Mvc
Assembly: HandlebarsDotNet.Mvc (in HandlebarsDotNet.Mvc.dll) Version: 1.0.0-beta
Syntax
public static void ScriptsRender(
	TextWriter writer,
	Object context,
	params Object[] arguments
)

Parameters

writer
Type: System.IOTextWriter
The TextWriter provided by HandlebarsDotNet
context
Type: SystemObject
The context (model) provided by HandlebarsDotNet
arguments
Type: SystemObject
The arguments from the view, provided by HandlebarsDotNet
Remarks
This helper is among the ones registered if RegisterMvcHelpers is called. If so, it is registered as scripts_render but you can choose your own name for this:
C#
var hbsve = new HandlebarsViewEngine();
hbsve.RegisterHelper("scripts_render", HandlebarsDotNet.Mvc.Helpers.ScriptsRender);
It works like https://msdn.microsoft.com/en-us/library/system.web.optimization.scripts.render.aspx.

Usage

{{scripts_render [path ...]}}

Arguments

string [path] (optional) - A set of virtual paths for which to generate script tags.

Description

This helper generates multiple script tags for each item in the bundle if EnableOptimizations is set to . When optimizations are enabled, it generates a single script tag to a version-stamped URL which represents the entire bundle.
See https://docs.microsoft.com/en-us/aspnet/mvc/overview/performance/bundling-and-minification for some general guidance about bundling.

The output is rendered with HandlebarsDotNet's WriteSafeString() meaning that using the triple-mustache is not needed.

Examples
This example assumes this helper has been registered as "scripts_render" and optimizations are enabled.
view.hbs
{{scripts_render "~/bundles/jquery"}}
Renders
<script src="/bundles/jquery?v=JzhfglzUfmVF2qo-weTo-kvXJ9AJvIRBLmu11PgpbVY1"></script>
See Also