0

I want to convert this embedded ruby html

<div ng-controller="PollCtrl" ng-init="polls = <%= @plan.polls.to_json %>">

and I've tried the following which raises an error

%div(ng-controller='PollCtrl', ng-init='polls = @plan.polls.to_json %>')

1 Answer 1

1

Use like

%div{"ng-controller" => "PollCtrl", "ng-init" => "polls = #{@plan.polls.to_json} "}

Which will produce

<div ng-controller="PollCtrl" ng-init="polls = <%= @plan.polls.to_json %> ">

Tested int haml2erb.org

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.