Rails: SCSS not being rendered correctly using haml - ruby-on-rails

https://gist.github.com/2597515
Note I used a html to haml converter. The sidebar partial is overlapping the main container, and the padding is messed up in some areas. Could this be because of my haml? Let me know.
Thanks!

It could definitely be because of your Haml code. The converter is not perfect and will never be perfect. You'll have to check the generated code by hand.

Related

Configure ckeditor in rails to write in Markdown syntax as opposed to HTML

In one part of my application I am successfully using creditor. It properly takes the text typed in and converts it into html format.
User Types in the content:
And it properly saves the content in html syntax:
In another place in my application I want to again use ckeditor. However: this time I want the content to be converted into Markdown syntax as opposed to HTML syntax. Is this possible? If so, how do you specify that configuration for this one place in the application (as opposed to globally specifying this rule because everywhere else I want ckeditor to continue converting the content into html).
I did look within the ruby gems ckeditor docs. I also looked through the ckeditor documentation on options, however looking through that was a bit overwhelming to me.
Seems like you have to add the markdown addon as it is not part of ckeditor, then follow the documentation.
What I ended up doing was creating a script that converted the database fields in my application that were in markdown syntax into html syntax. I did this with the redcarpet Gem and the rdiscount Gem. With those fields now saved in html syntax instead of markdown syntax, I rendered the text just like I do everywhere else where ckeditor is used.

html.haml to html.erb converter for Rails

I inherited a bunch of html.haml views in Rails project and want them to be html.erb.
Could you suggest some automatic Rails-aware converter?
Everything I've found is a set of HTML to HAML converters that additionally do not understand Rails.
You can use this converter to convert manually, link below
https://haml2erb.org/
I don't think any automatic html to erb converter is available as of now!

How to register rb as a template handler in rails

Well since I am using a lot of helper methods in my view files and I avoid using html in most of my view files.
Example
myview.html.erb
<%=myhelper #myobject%>
so I end up using,the erb processing tags each time for each file.
<%=%>
I want to register .rb as a template handler or any other extention for that matter.
So my templates look like
myview.html.rb
myhelper #myobject
I am clueless on how to go ahead.
I found it,it seems railscasts already covered that part.
Its show notes,worth checking out.
https://github.com/railscasts/379-template-handlers/blob/master/store-after/config/initializers/ruby_template_handler.rb
Things without ruby are easy to read and render without those erb tags.

Convert html to rails helpers

I am a RoR developer. I work with a graphic designer who prepares static html/css files and forward them to me.
Then I covert those html code to haml and include them in my views.
I use http://html2haml.heroku.com/ to covert html to haml. But it doesn't covert to haml using Rails helpers.
Example:
It converts
<img src="abc.png" />
To
%img{:src => "abc.png"}/
But I need it to be converted to
=image_tag "abc.png"
The same for other Rails helpers (link_to, text_field, ...etc)
Is there anything can make my work easier and converts using helpers?
I think, there's only one solution to this: your views should be built with Rails helpers from its beginning. There's many tools that can help create static views (which become your project views then), such as Serve or Middleman. The downside is that your designer should know about Rails helpers, haml etc, but this is a classical tradeoff.

WMD editor, rails, compass : How to get the generated Markdown code read as HTML and displayed as 'rich-text'?

I quite like that WMD is behaving nicely with my app. However, I have one problem.
Basically I edit content and store it as markdown in my database. Then I use Kramdown to get the HTML for the views. However Kramdown gets me the HTML tags which are not read by my browser. I use Chrome.
Sanitizing it will give a plain text even when the user has entered e.g. bold, italic, code etc.
So the basic idea is to get the generated HTML read as HTML and as 'rich-text'.
Inspecting the output source, I find that if I use Kramdown::Document.new(text).to_html there are some " " quotes introduce like this: "<p> ...<em>..</em>.. </p>"
These quotes hide the really HTML code after the quotes...(I assume)
and with sanitize the quotes are gone: <p> ...<em>..</em>.. </p> but I end up with plain text.
What am I missing here? Can I make my browser see that I have bold, or i have italic, a paragraph, an image etc...
Must I use kramdown or similar markdown to HMTL converters?
Thanks a lot!
UPDATE
I use compass for my stylesheets. When compass is uninstalled WMD editor works fine and correctly. For some reasons, it seems, compass hides any styles including 'test text' in my application.html.erb file but those created with its .scss partials files! I mean for example the following code when written in my application.html.erb file does not display as bold. <strong> test bold </strong>
Any ideas why this happens?
I have figured out the solution.
The problem was that the generated compass styles includes the following code segment:
body.bp {
#include blueprint-typography(true);
#include blueprint-utilities;
#include blueprint-debug;
#include blueprint-interaction;
// Remove the scaffolding when you're ready to start doing visual design.
// Or leave it in if you're happy with how blueprint looks out-of-the-box
}
In my stylesheets I had ignored to include the .bp class. All is good now...

Resources