https://github.com/stackbuilders/simple_templates
DEPRECATED: A minimalistic templating engine for Ruby
https://github.com/stackbuilders/simple_templates
archived deprecated obsolete
Last synced: 10 months ago
JSON representation
DEPRECATED: A minimalistic templating engine for Ruby
- Host: GitHub
- URL: https://github.com/stackbuilders/simple_templates
- Owner: stackbuilders
- License: mit
- Created: 2015-06-02T12:33:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-08-02T17:21:42.000Z (over 2 years ago)
- Last Synced: 2025-01-23T04:32:39.623Z (about 1 year ago)
- Topics: archived, deprecated, obsolete
- Language: Ruby
- Homepage:
- Size: 178 KB
- Stars: 0
- Watchers: 50
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/stackbuilders/simple_templates)
[](http://unmaintained.tech/)
> **⚠️ Warning:** This library has been deprecated and is no longer maintained. It will not receive any further security patches, features, or bug fixes and is preserved here at GitHub for archival purposes. If you want to use it, we suggest forking the repository and auditing the codebase before use. For more information, contact us at info@stackbuilders.com.
# DEPRECATED - simple_templates
`simple_templates` is a minimalistic templates engine. This gem allows you to
work with several types of templates.
## Installation
Clone the project
```
git@github.com:stackbuilders/simple_templates.git
```
Install the dependencies
```
bundle install
```
Run the tests
```
rake test
```
## Quick Start
The basic use of the library can be seen like this:
You can send a `String` with the raw input that includes your placeholders and
a list of `String` containing the allowed placeholders, if it is `nil`, then all
the placeholders are allowed.
A example without errors, that allows us to call the method `render`
```ruby
template = SimpleTemplates.parse("Hi ", %w[name])
template.render({ name: "Bob" }) if template.errors.empty?
=> "Hi Bob"
template.remaining_tokens
=> []
```
An example with errors. Since the allowed placeholder is not in the raw input.
So we get are going to get a list of errors when parsing
```ruby
template = SimpleTemplates.parse("Hi ", %w[date])
template.errors
=> [...] # unknown placeholder
```
### Serialization Support
You can serialize a template out of the box by calling the method `to_json`.
```ruby
template = SimpleTemplates.parse("Hi ", %w[name])
template.to_json
# => "{\"ast\":[{\"contents\":\"Hi...
```
You can also deserialize a serialized template.
```ruby
SimpleTemplates::Template.from_json(template.to_json)
# => #
[Check out our libraries](https://github.com/stackbuilders/) | [Join our team](https://www.stackbuilders.com/join-us/)