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.

4

1 回答 1

3

你需要的是基本的字符串插值,ruby on rails 语法如下:

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

在你的情况下:

%param{:name => "flashvars", :value => "controls=true&file=#{@video_resource.file_path}"}
                                                           ^^                         ^
于 2013-09-05T20:59:09.140 回答