appjudo / skim

Fat-free client-side templates with Slim and CoffeeScript
MIT License
273 stars 53 forks source link

How to use regex expression in control logic? #44

Open BartlomiejSkwira opened 9 years ago

BartlomiejSkwira commented 9 years ago

When I try to do:

- whatever = "hello world".replace(/ /g, '_')

I get

Uncaught Error: ExecJS::RuntimeError: SyntaxError: [stdin]:57:38: unexpected /
  (in /.../my_file.jst.skim)

There is a problem with / - ideas how to workaround this other then extracting that logic outside the .skim template?

Versions: Skim: 0.9.3 Slim: 2.0.2

gkopylov commented 9 years ago

Hi, @BartlomiejSkwira. I check your issue for master branch of Skim and Slim 3, and everything works fine. So this code:

- whatever = "hello world".replace(/ /g, '_')
- console.log whatever

outputs hello_world

You can update slim to version 3 and use this in your Gemfile:

gem 'skim', :git => 'https://github.com/jfirebaugh/skim.git'

or

gem 'skim', :git => 'https://github.com/gkopylov/skim.git', :branch => 'change_sprockets_version_dependency'

(if you want to use fresh version of sprockets gem).

And regard to Slim 2.0.2... I have not enough time to figure out with this issue, so you can just update versions or wait some time - may be someone else fix it.