I'm writing a Rails application and I have button that I create as follows:
<%= button_to t('.upload_html'), ... %>
where the ... stand for the other options. So the button should have the text pointed to by .upload_html and it does. Now I want that text to have two lines. In the YAML file I had
upload_html: "turn off"
and now I want
upload_html: "turn<br>off"
with a line break inside the button label text. But this does not work. It displays the string literally including the HTML tag without linebreaking. What can I do to force the line break?
Thank you!!
Best, Patrick
did you try "turn<br>off".html_safe ?
Related
I work a lot with ruby on rails so naturally I code a lot in erb. Typing <%= %> is always a pain so I wrote a keyboard shortcut script for in Key Bindings. Here is my code:
{"keys": ["ctrl+shift+e"], "command": "insert_snippet","args": {"contents": "<%= %>"}}
This is okay however this simply creates <%= %> and the cursor ends up after the > sign. How do I make it so that it creates <%= %> and the cursor ends up in between <%= and %> so I can start typing right away?
Thank you guys in advance!
{"keys": ["ctrl+shift+e"], "command": "insert_snippet","args": {"contents": "<%="$0"%>"}}
As per the documentation provided here placing the $0 would make the cursor move to that position. I also suggest you create an autocomplete mentioned here in this page.
https://sublime-text-unofficial-documentation.readthedocs.org/en/latest/extensibility/completions.html
I'm experiencing problems in Emacs when I edit web template code, i.e mixed php/html code or mixed ruby/html code. Emacs makes line breaks when it should not. The line breaks occurs when I enter a space somewhere on the line, very annoying...
How can I disable this behaviour?
Below is the kind of code I'm working with. If I would enter a space after one of the commas there, then Emacs will make a line break, sometimes multiple line breaks.
<% if #item.id %>
<b>Congratulations!The item was saved!
<%= button_to 'Preview the ad',#item,:method=>:get,:class => "btn add" %>
<% end %>
thanks!
It looks like for some reason auto-fill-mode is active (which you can check by looking for "Fill" in your modeline). If this is the case, you should turn it off:
M-xauto-fill-modeRET
To save this process for further sessions, you can put in your .emacs (after where it loads the mode specific stuff):
(auto-fill-mode nil)
Another thing is that you could embrace this feature; it is often good to have a limit on the amount of code you want to have in your screen.
Use M-x set-fill-column RET to set the amount of characters allowed on a line before it automatically breaks the line.
i am typing some text in my textbox like below format....:-
eg...
(hi i am xyz.
i work in a company which is product based.
and i work as a software engineer.)
after typing above text however i am pressing submit i am getting the below result in my view:-
(hi i am xyz.i work in a company which is product based.and i work as a software engineer.)
I am not getting how to get the display same as i have written in the textbox.
I will be highly thankful if someone help me.
Try putting it inside a pre tag.
<pre><%= #variable_name %></pre>
Or try simple_format
<%= simple_format(#variable_name) %>
Look into the simple_format helper:
my_text = "Here is some basic text...\n...with a line break."
simple_format(my_text)
# => "<p>Here is some basic text...\n<br />...with a line break.</p>"
You can also add the option to warp it with specific tags or perform sanitization.
I've been watching some Railscast episodes and it looks like he's using Sublime Text as his editor. How does he create new <% %> tags? I can tell he's using a shortcut but can't figure out what it is. Any help would be appreciated.
I really don't know what the "<% %> tags" are, but I imagine the presenter is using the ERB Insert and Toggle Commands add-on. The animated GIF on the project's description page shows such things being used.
I'm working on a Rails application and using HAML for the views. I would like to use the "sliding doors" technique to create pretty buttons, which means I need to get HAML to generate something similar to the following HTML:
<span class="button">Button text</span>
I haven't been able to figure out how to do that from the HAML reference or Google. Could you help please? Many thanks in advance.
EDIT: To clarify, I need to use the link_to helper because I'm linking to a resource. When I try to pass a block into the method, I get an error: undefined method 'stringify keys'
Try
= link_to invitation_path(invitation), :method=>:put, :class=>"button" do
%span(class="button")
Accept
This should be as simple as:
%a(href="#" class="button")
%span(class="button") Button text
Or if you especially want it on one line without any whitespace you can do:
%a(href="#" class="button")<
%span(class="button") Button text