-
Notifications
You must be signed in to change notification settings - Fork 1
RazorRenderCommandLine
knutkj edited this page Apr 29, 2012
·
2 revisions
How to install the Razor.Render.CommandLine NuGet package:
Install-Package Razor.Render.CommandLine
Razor Render CommandLine depends upon the AspNetRazor.Core NuGet package. This package contains the .NET assembly System.Web.Razor.dll. Razor Render CommandLine will try to load this assembly. If it fails you must add the reference. It can be done like this:
Add-Type -Path path\to\System.Web.Razor.dll
How to use Razor Render CommandLine:
SYNOPSIS
Renders the specified Razor template.
SYNTAX
Render-RazorTemplate [-Template] <String> [[-Model] <Object>] [<CommonParameters>]
DESCRIPTION
Renders the specified Razor template
with an optional model.
PARAMETERS
-Template <String>
A Razor template.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters?
-Model <Object>
A model to use in the template.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters?
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
C:\PS>Render-RazorTemplate -Template "Hello World!"
Output: Hello World!
-------------------------- EXAMPLE 2 --------------------------
Render-RazorTemplate "<ul>@foreach(var i in Model){<li>@i</li>}</ul>" (0..3)
Output: <ul><li>0</li><li>1</li><li>2</li><li>3</li></ul>