<commit_before>GRMustache.swift
================

GRMustache.swift is a [Mustache](http://mustache.github.io) template engine written in Swift 1.2, from the author of the Objective-C [GRMustache](https://github.com/groue/GRMustache).

It ships with built-in goodies and extensibility hooks that let you avoid the strict minimalism of the genuine Mustache language when you need it.

**June 9, 2015: GRMustache.swift 0.9.3 is out.** [Release notes](RELEASE_NOTES.md)

**SWIFT 2**: Check the [Swift2 branch](https://github.com/groue/GRMustache.swift/tree/Swift2).

Get release announcements and usage tips: follow [@GRMustache on Twitter](http://twitter.com/GRMustache).

Jump to:

- [Usage](#usage)
- [Documentation](#documentation)

Features
--------

- Support for the full [Mustache syntax](http://mustache.github.io/mustache.5.html)
- Filters, as `{{ uppercase(name) }}`
- Template inheritance, as in [hogan.js](http://twitter.github.com/hogan.js/), [mustache.java](https://github.com/spullara/mustache.java) and [mustache.php](https://github.com/bobthecow/mustache.php).
- Built-in [goodies](Docs/Guides/goodies.md)
- Unlike many Swift template engines, GRMustache.swift does not rely on the Objective-C runtime. It lets you feed your templates with ad-hoc values or your existing models, without forcing you to refactor your Swift code into Objective-C objects.


Requirements
------------

- iOS 7.0+ / OSX 10.9+
- Xcode 6.3


Usage
-----

`document.mustache`:

```mustache
Hello {{name}}
Your beard trimmer will arrive on {{format(date)}}.
{{#late}}
Well, on {{format(real_date)}} because of a Martian attack.
{{/late}}
```

```swift
import Mustache

// Load the `document.mustache` resource of the main bundle
let template = Template(named: "document")!

// Let template format dates with `{{format(...)}}`
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = .MediumStyle
template.registerInBaseContext("format", Box(dateFormatter))

// The rendered data
let data = [
    "name": "Arthur",
    "date": NSDate(),
    "real_date": NSDate().dateByAddingTimeInterval(60*60*24*3),
    "late": true
]

// The rendering: "Hello Arthur..."
let rendering = template.render(Box(data))!
```

Documentation
=============

To fiddle with the library, open the `Mustache.xcworkspace` workspace: it contains a Mustache-enabled Playground at the top of the files list.

External links:

- [The Mustache Language](http://mustache.github.io/mustache.5.html): the Mustache language itself. You should start here.
- [GRMustache.swift Reference](http://cocoadocs.org/docsets/GRMustache.swift/0.9.3/Classes/Template.html) on cocoadocs.org

Installing GRMustache.swift:

- [Installation](#installation)

Rendering templates:

- [Loading Templates](#loading-templates)
- [Errors](#errors)
- [Mustache Tags Reference](#mustache-tags-reference)
    - [Variable Tags](#variable-tags) `{{value}}`
    - [Section Tags](#section-tags) `{{#value}}...{{/value}}`
    - [Inverted Section Tags](#inverted-section-tags) `{{^value}}...{{/value}}`
    - [Partial Tags](#partial-tags) `{{>partial}}`
    - [Inherited Partial Tags](#inherited-partial-tags) aka Template Inheritance
    - [Set Delimiters Tags](#set-delimiters-tags) `{{=<% %>=}}`
    - [Comment Tags](#comment-tags) `{{! Wow. Such comment. }}`
    - [Pragma Tags](#pragma-tags) `{{% CONTENT_TYPE:TEXT }}`
- [The Context Stack and Expressions](#the-context-stack-and-expressions)

Feeding templates:

- [Templates Eat Boxed Values](#templates-eat-boxed-values)
- [Standard Swift Types Reference](#standard-swift-types-reference)
    - [Bool](#bool)
    - [Numeric Types](#numeric-types): Int, UInt and Double
    - [String](#string)
    - [Set](#set) (and similar collections)
    - [Array](#array) (and similar collections)
    - [Dictionary](#dictionary)
    - [NSObject](#nsobject)
    - [AnyObject and Any](#anyobject-and-any)
- [Custom Types](#custom-types)
- [Lambdas](#lambdas)
- [Filters](#filters)
- [Advanced Boxes](#advanced-boxes)

Misc:

- [Built-in goodies](#built-in-goodies)


Installation
------------

### iOS7

To use GRMustache.swift in a project targetting iOS7, you must include the source files directly in your project.


### CocoaPods

[CocoaPods](http://cocoapods.org/) is a dependency manager for Xcode projects.

To use GRMustache.swift with Cocoapods, specify in your Podfile:

```ruby
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

pod 'GRMustache.swift', '0.9.3'
```


### Carthage

[Carthage](https://github.com/Carthage/Carthage) is another dependency manager for Xcode projects.

To use GRMustache.swift with Carthage, specify in your Cartfile:

```
github "groue/GRMustache.swift" == 0.9.3
```


### Manually

Download a copy of GRMustache.swift, embed the `Mustache.xcodeproj` project in your own project, and add the `MustacheOSX` or `MustacheiOS` target as a dependency of your own target.


Loading Templates
-----------------

Templates may come from various sources:

- Raw Swift strings:

    ```swift
    let template = Template(string: "Hello {{name}}")!
    ```

- Bundle resources:

    ```swift
    // Loads the "document.mustache" resource of the main bundle:
    let template = Template(named: "document")!
    ```

- Files and URLs:

    ```swift
    let template = Template(path: "/path/to/document.mustache")!
    let template = Template(URL: templateURL)!
    ```
<commit_msg>Documentation WIP<commit_after>GRMustache.swift
================

GRMustache.swift is a [Mustache](http://mustache.github.io) template engine written in Swift 1.2, from the author of the Objective-C [GRMustache](https://github.com/groue/GRMustache).

It ships with built-in goodies and extensibility hooks that let you avoid the strict minimalism of the genuine Mustache language when you need it.

**June 9, 2015: GRMustache.swift 0.9.3 is out.** [Release notes](RELEASE_NOTES.md)

**SWIFT 2**: Check the [Swift2 branch](https://github.com/groue/GRMustache.swift/tree/Swift2).

Get release announcements and usage tips: follow [@GRMustache on Twitter](http://twitter.com/GRMustache).

Jump to:

- [Usage](#usage)
- [Installation](#installation)
- [Documentation](#documentation)

Features
--------

- Support for the full [Mustache syntax](http://mustache.github.io/mustache.5.html)
- Filters, as `{{ uppercase(name) }}`
- Template inheritance, as in [hogan.js](http://twitter.github.com/hogan.js/), [mustache.java](https://github.com/spullara/mustache.java) and [mustache.php](https://github.com/bobthecow/mustache.php).
- Built-in [goodies](Docs/Guides/goodies.md)
- Unlike many Swift template engines, GRMustache.swift does not rely on the Objective-C runtime. It lets you feed your templates with ad-hoc values or your existing models, without forcing you to refactor your Swift code into Objective-C objects.


Requirements
------------

- iOS 7.0+ / OSX 10.9+
- Xcode 6.3


Usage
-----

`document.mustache`:

```mustache
Hello {{name}}
Your beard trimmer will arrive on {{format(date)}}.
{{#late}}
Well, on {{format(real_date)}} because of a Martian attack.
{{/late}}
```

```swift
import Mustache

// Load the `document.mustache` resource of the main bundle
let template = Template(named: "document")!

// Let template format dates with `{{format(...)}}`
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = .MediumStyle
template.registerInBaseContext("format", Box(dateFormatter))

// The rendered data
let data = [
    "name": "Arthur",
    "date": NSDate(),
    "real_date": NSDate().dateByAddingTimeInterval(60*60*24*3),
    "late": true
]

// The rendering: "Hello Arthur..."
let rendering = template.render(Box(data))!
```


Installation
------------

### iOS7

To use GRMustache.swift in a project targetting iOS7, you must include the source files directly in your project.


### CocoaPods

[CocoaPods](http://cocoapods.org/) is a dependency manager for Xcode projects.

To use GRMustache.swift with Cocoapods, specify in your Podfile:

```ruby
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

pod 'GRMustache.swift', '0.9.3'
```


### Carthage

[Carthage](https://github.com/Carthage/Carthage) is another dependency manager for Xcode projects.

To use GRMustache.swift with Carthage, specify in your Cartfile:

```
github "groue/GRMustache.swift" == 0.9.3
```


### Manually

Download a copy of GRMustache.swift, embed the `Mustache.xcodeproj` project in your own project, and add the `MustacheOSX` or `MustacheiOS` target as a dependency of your own target.


Documentation
=============

To fiddle with the library, open the `Mustache.xcworkspace` workspace: it contains a Mustache-enabled Playground at the top of the files list.

External links:

- [The Mustache Language](http://mustache.github.io/mustache.5.html): the Mustache language itself. You should start here.
- [GRMustache.swift Reference](http://cocoadocs.org/docsets/GRMustache.swift/0.9.3/Classes/Template.html) on cocoadocs.org

Rendering templates:

- [Loading Templates](#loading-templates)
- [Errors](#errors)
- [Mustache Tags Reference](#mustache-tags-reference)
    - [Variable Tags](#variable-tags) `{{value}}`
    - [Section Tags](#section-tags) `{{#value}}...{{/value}}`
    - [Inverted Section Tags](#inverted-section-tags) `{{^value}}...{{/value}}`
    - [Partial Tags](#partial-tags) `{{>partial}}`
    - [Inherited Partial Tags](#inherited-partial-tags) aka Template Inheritance
    - [Set Delimiters Tags](#set-delimiters-tags) `{{=<% %>=}}`
    - [Comment Tags](#comment-tags) `{{! Wow. Such comment. }}`
    - [Pragma Tags](#pragma-tags) `{{% CONTENT_TYPE:TEXT }}`
- [The Context Stack and Expressions](#the-context-stack-and-expressions)

Feeding templates:

- [Templates Eat Boxed Values](#templates-eat-boxed-values)
- [Standard Swift Types Reference](#standard-swift-types-reference)
    - [Bool](#bool)
    - [Numeric Types](#numeric-types): Int, UInt and Double
    - [String](#string)
    - [Set](#set) (and similar collections)
    - [Array](#array) (and similar collections)
    - [Dictionary](#dictionary)
    - [NSObject](#nsobject)
    - [AnyObject and Any](#anyobject-and-any)
- [Custom Types](#custom-types)
- [Lambdas](#lambdas)
- [Filters](#filters)
- [Advanced Boxes](#advanced-boxes)

Misc:

- [Built-in goodies](#built-in-goodies)


Loading Templates
-----------------

Templates may come from various sources:

- Raw Swift strings:

    ```swift
    let template = Template(string: "Hello {{name}}")!
    ```

- Bundle resources:

    ```swift
    // Loads the "document.mustache" resource of the main bundle:
    let template = Template(named: "document")!
    ```

- Files and URLs:

    ```swift
    let template = Template(path: "/path/to/document.mustache")!
    let template = Template(URL: templateURL)!
    ```

{'fraction_non_alphanumeric': 0.16263940520446096, 'fraction_numerical': 0.007434944237918215, 'mean_word_length': 4.153735632183908, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6354824', 'n_tokens_mistral': 3634, 'n_tokens_neox': 3380, 'n_words': 935}