• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    C#
  • Created almost 13 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Static site generator using Razor.

Graze

Graze is a static site generator. It takes a template and a configuration file and generates a static web site. The generated site is pure HTML / CSS / JavaScript and can be hosted on any web server. The Graze templates are created using the "Razor Syntax": http://haacked.com/archive/2011/01/06/razor-syntax-quick-reference.aspx.

Breaking changes for new versions of Graze (moving from .NET Framework to .NET Core and .NET Standard)

Latest version of Graze has been updated from .NET Framework to .NET Core 3.1 and .NET Standard 2.0. This currently causes two breaking changes, one for layouts and one for raw HTML:

  1. Reference to layout file using Layout, instead of _Layout like before.
  2. For now, the HTML is encoded by default and the only way to get around this is set DisableEncoding = true; in your cshtml-file.

Here's an example index.cshtml where both of these changes are done:

@{
    Layout = "./Layout.cshtml";
    ViewBag.Title = Model.Description;
    DisableEncoding = true;
}

<h1>@Model.Description</h1>
...

Getting started

  1. Download the latest release (zip contains a sample): https://github.com/mikoskinen/graze/releases/tag/7.0.0
  2. Run graze.exe

(Note: You may have to "Unblock" the DLL-files in extras-folder)

The static site (index.html) is generated into the output folder.

NuGet

Graze is also available from the NuGet. To get started, first create a new "Empty Project" with Visual Studio and then add the Graze using NuGet. Graze.exe and the template-folder are installed into the root of your project.

Install-Package graze

Graze templates

The Graze templates are created using the Razor syntax. Here's an example:

<html>
<head>
    <title>@Model.Title</title>
</head>
<body>
    <h1>@Model.Description</h1>
</body>
</html>

Graze configuration

The configuration for Graze is done in XML. Here's an example configuration:

<?xml version="1.0" encoding="utf-8" ?>
<data>
	<site>
		<Title>Graze</Title>
		<Description>Graze: Static site generator using Razor</Description>
	</site>
</data>

The configuration file represents the data which is injected to the generated static site.

Generating the static site

Once the Graze template and the configuration file are in place, the static site can be generated running the graze.exe. The static site is generated into the output-folder.

<html>
<head>
    <title>Graze</title>
</head>
<body>
    <h1>Graze: Static site generator using Razor</h1>
</body>
</html>

Features

Dynamic configuration

The configuration.xml represents the data which is shown on the generated site. In the template you can access a configuration parameter using the @Model-keyword. New configuration options can be added freely and old ones can be removed.

Lists and loops

Lists can be created in XML and accessed in the Graze template. Example XML:

  <Features>
    <Feature>Layouts defined using Razor syntax.</Feature>
    <Feature>Dynamic data models created in XML.</Feature>
    <Feature>Supports complex data models and arrays.</Feature>
    <Feature>Fast static site generation.</Feature>
    <Feature>Pure HTML / CSS / Javascript output. Host in Apache, IIS etc.</Feature>
  </Features>

Example template for accessing the list:

    <h2>Features:</h2>
    <ul>
        @foreach (var feature in Model.Features)
        {
            <li>@feature</li>
        }
    </ul>

Ifs

The programming language behind the Graze template is C# so if and if-else statements are available. Given the following configuration:

  <Family>
	<Member Age="50">Saul</Member>
	<Member Age="31">Claire</Member>
	<Member Age="11">John</Member>
  </Family>

We can output different HTML from our template based on the member's age

	@foreach(var member in @Model.Family)
	{
		var membersAge = int.Parse(member.Age);
		
		if (membersAge >= 18)
		{
			<p>@member.Member is an adult</p>
		}
		else
		{
			<p>@member.Member is a child</p>
		}
	}

Generated output:

			<p>Saul is an adult</p>
			<p>Claire is an adult</p>
			<p>John is a child</p>

Complex types

By default all the data in the XML is of type string when accessed from the template. But complex types can be created also:

<Link Url="https://github.com/mikoskinen/graze">Source code hosted in GitHub</Link>
<a href="@Model.Link.Url">@Model.Link.Link</a>

Case sensitive

The configuration and the templates are case sensitive.

Extras

The Graze's core can create the site's model from the configuration file's site-element. But, the model can be enhanced using extras. Graze comes bundled with the following extras:

  • Markdown
  • HTML
  • RSS
  • YouTube

The example template bundled with the Graze shows how to use these model enhancers.

Folder structure

Graze expects the following folder structure:

graze.exe
--template/
----configuration.xml
----index.cshtml
----assets

The assets folder is copied wholly to the output folder. The assets folder can include the CSS / JSS / image files required by the template.

!https://github.com/mikoskinen/graze/raw/master/doc/drawing_small.png!

License


MIT License
Copyright (C) 2019 Mikael Koskinen

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Other libraries

Graze uses the following libraries:

More Repositories

1

Blazor.Animate

Easily add fade, slide and zoom-effects into your Blazor applications.
C#
270
star
2

Blazor.EventAggregator

Lightweight Event Aggregator for Blazor (Razor Components).
C#
117
star
3

blog

Source codes from my blog posts
C#
53
star
4

Blazor.AdaptiveCards

Adaptive Cards for Blazor
C#
49
star
5

SQLLint

SQLLint is a web based reformatter and beautifier for SQL.
CSS
40
star
6

socketex

TcpClient for Windows Phone
C#
16
star
7

GrazeDocs

Static site generator for creating documentation for your projects
C#
15
star
8

Blazor.Page

Page base component for Blazor pages. Easily update page title and optionally inject datacontext into your page.
C#
9
star
9

vssbindingremover

VSS Binding Remover strips out the Visual Source Safe related sections from the Visual Studio solution and project files
C#
9
star
10

NSQLFormatter-dotnet

Beautify your SQL easily. NSQLFormatter is an open-source SQL Beautifier written with C# and .NET Framework 4.0. Project is based 100% on the work done in the NHibernate-project.
C#
9
star
11

grazewp7

Windows Phone 7 app marketing web site Generator using Graze and Twitter Bootstrapper.
JavaScript
8
star
12

UWPResponsiveXAMLLayoutGridAdaptiveTrigger

Example of how to use repositioning to create a responsive layout for your XAML Universal Windows app (UWP) using Grid and AdaptiveTrigger.
C#
7
star
13

UWP.MDI

Multiple document interface (MDI) support for UWP applications
C#
7
star
14

ircbot-dotnet

Irc bot built with easy extensibility in mind. Written with C#, the bot provides a platform on which to add new features and functionality easily.
C#
7
star
15

Caliburn-Micro-WinRT-Callisto-Helpers

Helper classes for showing Callisto dialogs with Caliburn.Micro
C#
4
star
16

AttachToDotnet

Extension for Visual Studio 2017/2019 which makes it easier to attach to the correct dotnet.exe process
C#
4
star
17

SubtitleProvider

Subtitle plugin for MediaBrowser. The plugin adds an automatic subtitle downloading to MediaBrowser.
C#
4
star
18

node-web-api-benchmark

Codes for the Node.js vs ASP.NET Web Api benchmarks
C#
4
star
19

irc7

The Windows Phone IRC chat app
3
star
20

AzureBlobBridgeIFTTT

Azure Blob Bridge for IFTTT provides an easy way to use Azure Blob storage as a IFTTT Action.
C#
3
star
21

OcelotIdentityServerAzureAdWithApi

Demo for a scenario where API is accessed through Ocelot gateway and Ocelot uses IdentityServer and Azure Ad for authentication
C#
3
star
22

wordpress-sql-azure

Wordpress with SQL Azure
PHP
2
star
23

NXMLFormatter

NXMLFormatter is an open-source XML Beautifier written with C#.
C#
2
star
24

NCompileBench

Compilation benchmark for Windows. How fast can your computer compile .NET code?
C#
2
star
25

softwaremkwebsource

www.softwaremk.org
CSS
1
star
26

websitetest

1
star
27

grazeblog

Blog platform based on Graze templating engine.
1
star
28

UWPEventAggregator

Simple event aggregator for Multi Window UWP apps
C#
1
star
29

uwpusercontrollistdp

C#
1
star
30

durandal-phonegap-windows-phone-sample

A sample which shows how to use Durandal in a PhoneGap based Windows Phone app.
JavaScript
1
star
31

ipsnoop

The website for IP Snoop app for Windows Phone 7
1
star
32

link

Standalone host for the ASP.NET Web Api
1
star
33

ampparit

Ampparit.com Reader website
1
star
34

UWP-SemanticZoom-GridView

Sample UWP app which shows how to use SemanticZoom with GridView
C#
1
star
35

uwpusercontrolbinding

C#
1
star
36

softwaremkassets

JavaScript
1
star
37

softwaremkwebsite

www.softwaremk.org
JavaScript
1
star
38

marketwatcher

Windows Phone class library which fetches reviews for a desired app from the Windows Marketplace.
C#
1
star
39

aurelia-uwp

Sample of creating an Aurelia-based UWP app
JavaScript
1
star
40

movieposters

Website for Movie Poster for Windows Phone 7
1
star