Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4615

Using Ruby and Sinatra, Is it possible to use HAML in an "internal" or "inline" manner?

$
0
0

I've done gem install sinatra and gem install haml

And I have this .rb file

require 'sinatra'get '/abc2' do"<b>aaaaaaaaaaaaa</b>"end

Now say I want that line of HTML but in HAML. and not externally

I know I can do

get '/abc' do  haml :index  # /views/index.haml end

And index.haml could have a line of haml %b aaaaaaa

But is there any way that I can include %b aaaaaaa in my ruby file itself and have it rendered. Without having to refer to a file e.g. without having to refer to /views/index.haml ?

Like CSS lets you have the CSS External, or it lets you have it internal within the html file.. Similarly, Javascript lets you import javascript externally, or it lets you have it internal to the html file.. Well i'm asking about using HAML internally to the .rb file. Is it possible?

I know HAML is intended as a template language for injecting data into.. but it is also a shorthand for writing HTML more concisely.


Viewing all articles
Browse latest Browse all 4615

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>