Skip to content

Instantly share code, notes, and snippets.

@eduardo
Created August 12, 2008 11:13
Show Gist options
  • Select an option

  • Save eduardo/5027 to your computer and use it in GitHub Desktop.

Select an option

Save eduardo/5027 to your computer and use it in GitHub Desktop.
def ver
alt = (self.tipo == "Lateral" ? self.altura_lateral : self.altura)
if self.formato == "Flash"
html="<a href=\"#{self.url_destino.pon_http}\" title=\"#{self.texto}\">"
html+=" <object class=\"#{self.tipo == 'Superior' ? 'banner-top' : 'hotelrecomendado'}\">"
html+=" <param name=\"movie\" value=\"#{self.url_imagen.pon_http}\">"
html+=" <embed src=\"#{self.url_imagen.pon_http}\" width=\"#{self.anchura}\" height=\"#{alt}\">"
html+=" </embed>"
html+=" </object>"
html+="</a>"
elsif self.formato == "Imagen"
html="<a href=\"#{self.url_destino.pon_http}\" title=\"#{self.texto} #{self.detalles}\">"
html+=" <img src=\"#{self.url_imagen.pon_http}\" alt=\"#{self.texto} #{self.detalles}\" width=\"#{self.anchura}\" height=\"#{alt}\">"
html+="</a>"
elsif self.formato == "Bloque personalizado"
eval(self.html)
elsif self.formato == "HTML"
ERB.new(self.html).result
end
end
end
Loading development environment (Rails 2.1.0)
>> # para codigo ruby
?> html = "@valor.to_s + ' es el resultado'"
=> "@valor.to_s + ' es el resultado'"
>> @valor = 42
=> 42
>> eval(html)
=> "42 es el resultado"
>> # para ERB (rhtml)
?> html = ERB.new("<%= @valor %> es el resultado")
=> #<ERB:0x4fd8b54 @src="_erbout = ''; _erbout.concat(( @valor ).to_s); _erbout.concat \" es el resultado\"; _erbout", @filename=nil, @safe_level=nil>
>> html.result
=> "42 es el resultado"
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment