Skip to content

Commit

Permalink
Tidy readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuvist committed Jul 14, 2019
1 parent 361c6c6 commit 60dcf08
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)
[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)

gorazor is the Go port of the razor view engine originated from [asp.net in 2011](http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx). In summary, gorazor's:
`gorazor` is the Go port of the razor view engine originated from [asp.net in 2011](http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx). In summary, `gorazor` is:

* Extremely Fast. Templates are converted into Go code and then compiled with optimization.
* Concise syntax, no delimiter like `<?`, `<%`, or `{{`.
Expand All @@ -21,7 +21,7 @@ gorazor is the Go port of the razor view engine originated from [asp.net in 2011
* Embedding templates support
* Layout/Section support

# Extremely Fast Performance
# Extremely Fast

`gorazor` is about **20X** times faster than [html/template](https://golang.org/pkg/html/template/) when using standard `strings.Builder` for template writing.

Expand Down Expand Up @@ -58,11 +58,11 @@ ok github.com/sipin/gorazor/tests 19.921s
```

* `BenchmarkRazorQuickTemplate`'s manually modified ensure **exact output** as quicktemplate for comparism.
* `BenchmarkRazorQuickTemplateOriginal` are gorazor's default code-gen, which produce less white-space, thus faster.
* `BenchmarkRazorQuickTemplateOriginal` are `gorazor`'s default code-gen, which produce less white-space, thus faster.

# Usage

gorazor supports `go 1.10` and above, for go version **below 1.10**, you may use [gorazor classic version](https://github.com/sipin/gorazor/releases/tag/v1.0).
`gorazor` supports `go 1.10` and above, for go version **below 1.10**, you may use [gorazor classic version](https://github.com/sipin/gorazor/releases/tag/v1.0).

`go 1.12` are recommneded for better **compiler optimization**.

Expand All @@ -74,8 +74,8 @@ go get github.com/sipin/gorazor

## Usage

* `gorazor template_folder output_folder`
* `gorazor template_file output_file`
* Process folder: `gorazor template_folder output_folder`
* Process file: `gorazor template_file output_file`

## Examples

Expand Down Expand Up @@ -152,7 +152,7 @@ Please use [example](https://github.com/sipin/gorazor/blob/master/examples/tpl/h

## Code block

It's possible to insert arbitrary go code block in the template, like create new variable.
Arbitrary go code could be used in template, like create new variable.

```html
@{
Expand All @@ -166,7 +166,7 @@ It's possible to insert arbitrary go code block in the template, like create new
</div>
```

It's recommendation to keep clean separation of code & view. Please consider move logic into your code before creating a code block in template.
It's recommended to keep clean separation of code & view. **Please consider** move logic into your code before creating a code block in template.

## Declaration

Expand Down Expand Up @@ -204,7 +204,7 @@ If your template doesn't need any model input, then just leave it blank.

## Helper / Include other template

As gorazor compiles templates to go function, embedding another template is just calling the generated function, like any other go function.
As `gorazor` compiles templates to go function, embedding another template is just calling the generated function, like any other go function.

However, if the template are designed to be embedded, it must be under `helper` namespace, i.e. put them in `helper` sub-folder.

Expand All @@ -218,7 +218,7 @@ So, using a helper template is similar to:

```

gorazor won't HTML escape the output of `helper.XXX`.
`gorazor` won't HTML escape the output of `helper.XXX`.

Please use [example](https://github.com/sipin/gorazor/blob/master/examples/tpl/home.gohtml) for reference.

Expand All @@ -243,7 +243,7 @@ The syntax for declaring layout is a bit tricky, in the example mentioned above:
### Package / Variable convention

* The namespace/folder name for layout templates **must be** `layout`
* gorazor relies on this to determine if a template for layout
* `gorazor` relies on this to determine if a template for layout
* The template `variable name` also **must be** `layout`

A layout file `tpl/layout/base.gohtml` may look like:
Expand Down Expand Up @@ -273,7 +273,7 @@ A layout file `tpl/layout/base.gohtml` may look like:
</html>
```

It's just a usual gorazor template, but:
It's just a usual `gorazor` template, but:

* First param must be `var body string` (As it's always required, maybe we could remove it in future?)
* All params **must be** string, each param is considered as a **section**, the variable name is the **section name**.
Expand Down Expand Up @@ -360,13 +360,8 @@ Here is a simple example of [gorazor templates](https://github.com/sipin/gorazor

### Sublime Text 2/3

**Syntax highlight** Search & install `gorazor` via Package Control.

![syntax highlight](https://lh4.googleusercontent.com/-_mhaTNt04aU/U7kaSbSXCMI/AAAAAAAAH48/06DintuZPVE/w875-h770-p/Screen+Shot+2014-07-06+at+2.17.49+PM.png)

**Context aware auto-completion**, you may need to [manually modify](https://github.com/sipin/GoSublime/commit/fd0b979e7cc1d8f2438bb314399c2456d16f3ffb) GoSublime package, bascially replace `gscomplete.py` in with [this](https://raw.githubusercontent.com/sipin/GoSublime/gorazor/gscomplete.py) and `gslint.py` with [this](https://raw.githubusercontent.com/sipin/GoSublime/gorazor/gslint.py)

![auto complete](https://lh5.googleusercontent.com/-A95EdOJGVv8/U7kaSdMkP-I/AAAAAAAAH5A/5ZI4z7X2l_Y/w958-h664-no/Screen+Shot+2014-07-05+at+10.38.22+PM.png)
* **Syntax highlight** Search & install `gorazor` via Package Control.
* **Context aware auto-completion**, you may need to [manually modify](https://github.com/sipin/GoSublime/commit/fd0b979e7cc1d8f2438bb314399c2456d16f3ffb) GoSublime package, bascially replace `gscomplete.py` in with [this](https://raw.githubusercontent.com/sipin/GoSublime/gorazor/gscomplete.py) and `gslint.py` with [this](https://raw.githubusercontent.com/sipin/GoSublime/gorazor/gslint.py)

### Emacs
[web-mode](http://web-mode.org/) supports Razor template engine, so add this into your Emacs config file:
Expand All @@ -382,9 +377,9 @@ Here is a simple example of [gorazor templates](https://github.com/sipin/gorazor

# Credits

The very [first version](https://github.com/sipin/gorazor/releases/tag/vash) of gorazor is essentially a hack of razor's port in javascript: [vash](https://github.com/kirbysayshi/vash), thus requires node's to run.
The very [first version](https://github.com/sipin/gorazor/releases/tag/vash) of `gorazor` is a hack of razor's port in javascript: [vash](https://github.com/kirbysayshi/vash), thus requires node's to run.

gorazor has been though several rounds of refactoring and it has completely rewritten in pure Go. Nonetheless, THANK YOU [@kirbysayshi](https://github.com/kirbysayshi) for Vash! Without Vash, gorazor may never start.
`gorazor` has been though several rounds of refactoring and it has completely rewritten in pure Go. Nonetheless, THANK YOU [@kirbysayshi](https://github.com/kirbysayshi) for Vash! Without Vash, `gorazor` may never start.

# LICENSE

Expand Down

0 comments on commit 60dcf08

Please sign in to comment.