Bump Tilt to 1.4.1 to get its better encoding support #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tilt introduced better encoding support in version 1.4.0. In particular, this allows Stasis to correctly handle UTF-8 encoded template files (e.g., CoffeeScript) with extended Unicode characters.
For example, when a CoffeeScript file contains a string with a ↑ character (U+2191, UTF-8: E2 86 91), Stasis 0.2.0 fails with the following error:
[2013-10-24 15:01:54] Error: "\xE2" from ASCII-8BIT to UTF-8
Stasis::Options.set_template_option
will pass options to Tilt for a given template type and force UTF-8 encoding in CoffeeScript templates, but Tilt 1.3.3 does not support any template encoding options. A magic comment (e.g.,# coding: utf-8
) does not appear to force UTF-8 encoding in a CoffeeScript file through Tilt.However, the following was added to the
Tilt::Template
base class constructor in 1.4.0:This means that I can add this to a controller:
which would then make Tilt call
force_encoding('UTF-8')
on all CoffeeScript templates it processes.The only catch I found to bumping Stasis to Tilt 1.4.1 is that Tilt 1.3.4 introduced a no-op "template" for files ending in .html. This breaks some of the default copying behavior (and 4 of the tests). The simplest way to address this is to reach into Tilt and remove the template.
If I've completely overlooked a much simpler way to include Unicode characters in CoffeeScript via Stasis, please let me know. I couldn't find anything obvious and this seemed to be the most flexible solution.