-
Notifications
You must be signed in to change notification settings - Fork 50
Description
One occasionally wants to use Rails helper methods (especially asset and route helpers) in client-side templates. Existing solutions are ugly.
The fact that Skim is implemented in Ruby and compiles server-side affords a unique solution: server-side evaluation within the language. I'm thinking of adding two new sigils: ~ and ≈, server-side analogs of - and =. (Think of ~ as a sideways S, for Server.) Within these sigils, you write Ruby instead of CoffeeScript. You are responsible for keeping your template logic simple enough that writing in two different embedded languages doesn't become confusing.
Example:
a href≈my_path
≈ image_tag "logo.png"
my_path and image_tag would be evaluated at compile time, generating the equivalent of:
a href="/my/path"
img src="/assets/logo.png"
Maybe ≈ isn't the best choice, as it's hard to type and forces the encoding issue. But you get the idea.