1

Hey I am fairly new to web programming, so please excuse my ignorance. I have the following code in a .html.haml view file.

%video{:controls => "controls", :height => "240", :width => "320"}
  %source{:src => @video_resource.file_path, :type => "video/mp4"}/
  %source{:src => @video_resource.file_path, :type => "video/webm"}/
  %source{:src => @video_resource.file_path, :type => "video/ogg"}/
  %object{:data => "flashmediaelement.swf", :height => "240", :type => "application/x-shockwave-flash", :width => "320"}
    %param{:name => "movie", :value => "flashmediaelement.swf"}/
    %param{:name => "flashvars", :value => "controls=true&file=movie.url"}/
  = t('html5_video_error')

How do I get @video_resource.file_path into the flashvars object param file variable (currently it is set to movie.url). I may be misunderstanding the way this works.

1
  • :value => "controls=true&file=#{@video_resource.file_path}" should do it Commented Sep 5, 2013 at 20:42

1 Answer 1

3

What you need here is basic string interpolation, the ruby on rails syntax is the following:

# haml code:
%span= "I am a #{ 'interpolated' } string"
# will render:
<span>I am a interpolated string</span>

In your case:

%param{:name => "flashvars", :value => "controls=true&file=#{@video_resource.file_path}"}
                                                           ^^                         ^
Sign up to request clarification or add additional context in comments.

1 Comment

That's what I was looking for. I wanted to print string characters with "END\n" in my input as a placeholder so doing it as placeholder: "eg. #{'END\n'}"}

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.