Lightweight command line over RazorEngine
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.nuget
Mono.Options
Properties
wwwtest
.gitignore
App.config
Hyde.csproj
Hyde.sln
Hyde.sln.DotSettings
Program.cs
README.md
packages.config

README.md

Hyde - build a static website using Razor and the command line

Lightweight command line over RazorEngine. Quick hour hack for a project I'm working on to put a very simple command line over RazorEngine to build a static website using Razor templates.

Example

  1. Copy Hyde.exe, RazorEngine.dll and System.Web.Razor.dll to the same folder.

  2. Create one or more templates saved as .cshtml.

@{
 Layout = "layout.cshtml";
}
<h2>@Model.H2</h2>
<div>@Model.IndexContent</div>      
  1. Optionally create one or more layouts saved as .cshtml.
<!doctype html>
<html>
<head>
    <title>@Model.Title</title>
</head>
<body>
    <h1>Layout.cshtml</h1>
    @RenderBody()
</body>
</html>
  1. Open a command prompt and type:
Hyde -source c:\path_to_cshtml
-layouts c:\path_to_layout_cshtml
-json "{Title:'Test Hyde', H2:'Test Heading', IndexContent:'Some Test content for index'}"
-output c:\path_to_output_static_site

This will parse all the .cshtml in -source c:\path_to_cshtml,

with the -layout(s) c:\path_to_layout_cshtml,

using the model specified in -json {Title:'Test Hyde', H2:'Test Heading', IndexContent:'Some Test content for index'}",

which will -output the static html to c:\path_to_output_static_site

Output

<!doctype html>
<html>
<head>
    <title>Test Hyde</title>
</head>
<body>
    <h1>Layout.cshtml</h1>    
    <h2>Test Heading</h2>
    <div>
       Some Test content for index
    </div>
</body>
</html>