Skip to content

Commit

Permalink
Merge pull request #38 from cbroglie/logo
Browse files Browse the repository at this point in the history
Add logo to readme
  • Loading branch information
cbroglie authored Feb 19, 2020
2 parents f164316 + 751ce30 commit 7b1d416
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
[![Downloads](https://img.shields.io/github/downloads/cbroglie/mustache/latest/total.svg)](https://github.com/cbroglie/mustache/releases)
[![Latest release](https://img.shields.io/github/release/cbroglie/mustache.svg)](https://github.com/cbroglie/mustache/releases)


<img src="./images/logo.jpeg" alt="logo" width="100"/>

----

## Why a Fork?

I forked [hoisie/mustache](https://github.com/hoisie/mustache) because it does not appear to be maintained, and I wanted to add the following functionality:

- Update the API to follow the idiomatic Go convention of returning errors (this is a breaking change)
- Add option to treat missing variables as errors

----

## CLI Overview

```bash
Expand All @@ -31,6 +38,8 @@ Flags:
~
```

----

## Package Overview

This library is an implementation of the Mustache template language in Go.
Expand All @@ -39,16 +48,22 @@ This library is an implementation of the Mustache template language in Go.

[mustache/spec](https://github.com/mustache/spec) contains the formal standard for Mustache, and it is included as a submodule (using v1.1.3) for testing compliance. All of the tests pass (big thanks to [kei10in](https://github.com/kei10in)), though the optional lambda support has not been implemented.

----

## Documentation

For more information about mustache, check out the [mustache project page](http://github.com/defunkt/mustache) or the [mustache manual](http://mustache.github.com/mustache.5.html).

Also check out some [example mustache files](http://github.com/defunkt/mustache/tree/master/examples/)

----

## Installation

To install mustache.go, simply run `go get github.com/cbroglie/mustache/...`. To use it in a program, use `import "github.com/cbroglie/mustache"`

----

## Usage

There are four main methods in this package:
Expand Down Expand Up @@ -83,10 +98,14 @@ for i := 0; i < 10; i++ {

For more example usage, please see `mustache_test.go`

----

## Escaping

mustache.go follows the official mustache HTML escaping rules. That is, if you enclose a variable with two curly brackets, `{{var}}`, the contents are HTML-escaped. For instance, strings like `5 > 2` are converted to `5 &gt; 2`. To use raw characters, use three curly brackets `{{{var}}}`.

----

## Layouts

It is a common pattern to include a template file as a "wrapper" for other templates. The wrapper may include a header and a footer, for instance. Mustache.go supports this pattern with the following two methods:
Expand Down Expand Up @@ -127,6 +146,8 @@ A call to `RenderFileInLayout("template.html.mustache", "layout.html.mustache",
</html>
```

----

## Custom PartialProvider

Mustache.go has been extended to support a user-defined repository for mustache partials, instead of the default of requiring file-based templates.
Expand Down Expand Up @@ -168,6 +189,8 @@ sp := StaticProvider(map[string]string{
tmpl, err := ParseStringPartials("This partial is loaded from a map: {{>foo}}", sp)
```

----

## A note about method receivers

Mustache.go supports calling methods on objects, but you have to be aware of Go's limitations. For example, lets's say you have the following type:
Expand Down
Binary file added images/logo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7b1d416

Please sign in to comment.