{"repo":"amatsuda/string_template","free":true,"listed":false,"github":"https://github.com/amatsuda/string_template","clone":"git clone https://github.com/amatsuda/string_template.git","description":"A template engine for Rails, focusing on speed, using Ruby's String interpolation syntax","language":"Ruby","stars":124,"topics":["ruby","rails","template","template-engine"],"license":"MIT","category":"saas-starters-boilerplates","readme_excerpt":"StringTemplate The fastest template engine for Rails. Concept Ruby's String literal has such a powerful interpolation mechanism. It's almost a template engine, it's the fastest way to compose a String, and the syntax is already very well known by every Ruby programmer. Why don't we use this for the view files in our apps? Installation Add this line to your Rails application's Gemfile: And then bundle. Syntax StringTemplate's syntax is based on Ruby's String interpolation. Plus, you can use Action View features. Example Here's an example of a scaffold generated ERB template, and its string\\ template version. ERB: string\\ template: More Examples Please take a look at the tests for actual examples. File Names By default, string\\ template renders view files with .string extension, e.g. app/views/posts/show.html.string Security string\\ template does not automatically html escape . Don't forget to explicitly call h() when interpolating possibly HTML unsafe strings, like we used to do in pre Rails 3 era. So, Should We Rewrite Everything with This? string\\ template may not be the best choice as a general purpose template engine. It may sometimes be hard to express your template in a simple and maintainable code, especially when the template includes some business logic. You need to care about security. So this template engine is recommended to use only for performance hotspots. For other templates, you might better use your favorite template engine such as haml, or haml, or haml. Ben","default_branch":null,"files":null,"tree":[],"storefront":"/r/amatsuda","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/amatsuda/string_template/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}