Antarr Byrd
Antarr Byrd

Reputation: 26131

Convert haml js to slim

I'm trying to convert a haml template to slim. The view includes javascript. I am getting an error saying expected closing '}' when accessing the slim view that was generated using haml2slim. How can I convert the js below to working in slim?

_.haml

:javascript
  var client = new Client({
    projectId: "#{ENV['...']}",
    readKey: "#{..::ReadKey.new(
                  ENV['..'], {
                  filters:  [{
                    property_name: "account_id",
                    operator: "eq",
                    property_value: @account.id
             }]}).encrypt!}"
  });

haml2slim

javascript:
  | var client = new Client({
    | projectId: "#{ENV['...']}",
    | readKey: "#{...::ReadKey.new(
                  | ENV['...'], {
                  | filters:  [{
                    | property_name: "account_id",
                    | operator: "eq",
                    | property_value: @account.id
             | }]}).encrypt!}"
  | });

Upvotes: 0

Views: 449

Answers (1)

Josh
Josh

Reputation: 5721

I believe the colon should come after javascript like this:

javascript:
  var client = new Client({
    projectId: "#{ENV['...']}",
    readKey: "#{..::ReadKey.new(
                  ENV['..'], {
                  filters:  [{
                    property_name: "account_id",
                    operator: "eq",
                    property_value: @account.id
             }]}).encrypt!}"
  });

Upvotes: 1

Related Questions