Is there a package or snippet I can use to activate autocompletion for ERB (.html.erb) files in Sublime?
I'm not talking about shortcuts like https://github.com/eddorre/SublimeERB provides. I want to start typing "<%" and than Sublime to offer me the autocomplete suggestions "<% %>, <%= %>..." similar to what happens when I enter "<d" Sublime suggest the "<div>" tag autocompletion.
I recommend using ERB snippet, it covers major erb tags
https://github.com/matthewrobertson/ERB-Sublime-Snippets
I use this:
https://github.com/eddorre/SublimeERB#add-keybinding
Follow the simple instructions in the README.
Related
I am trying Visual Studio Code lately and i've noticed that when i try to add a line comment in an HTML file (using Ctrl+/ or Ctrl+K Ctrl+C) instead of this: <!-- -->, i get this {# #}.
In JS or CSS files the key bindings work just fine and produce the expected result.
So how can i get the proper type of comments in HTML files?
Finally i found what the problem was. I had installed the twig plugin (for the Twig php template engine) and that was causing the comments issue.
I've just installing VSCode 1.1.1 and try to put a comment in an new html file
To do so, your new file must be,first, save in .html format and after that, you can use CTRL-K CTRL-C to put a comment and it works.
Hope that help you
If you don't want to disable/uninstall any plugin, you can create a snippet to put a comment. For example, I create a snippet that add HTML comments in a PHP file:
"comment HTML": {
"prefix": "chtml",
"body": ["<!-- $1 -->"],
"description": "Comment HTML line"
}
You can insert that right after the comment in File > Preferences > User Snippets > {YourExtension}
Then, when you start typing 'chtml' in that kind of files, IntelliSense will prompt that snippet.
Maybe this is a workarround, but it works excellent for me. Hope it helps!
https://code.visualstudio.com/docs/customization/userdefinedsnippets
For me, it was the (Djaneiro) extension, it made the html files default to django template, so it caused the comments to be wrong in HTML (when pressing ctrl + / )
(commenting them with {% comment %})
List of extensions known to cause this unwanted behavior (Based on my own experience and other answers):
Hugo Language and Syntax Support
Djaneiro
Nunjucks
Tornado
Sublime Babel
Babel
Twig
Django by Baptiste Darthenay (v1.0.0)
(Feel free to edit this answer and add yours)
You may need to restart code after disabling your extension (I did).
In your Visual Studio Code windows, go to File->Preferences->Keyboard Shortcut
This will open two files beside each other like in the screenshot below:
here you can change or create your own shortcuts.
Like I just replaced Ctrl+KU to Ctrl+/
Hope this will work for you !!
For me, the offending extension was Nunjucks (the templating language plugin assumes every .html file is a nunjucks html template)
For others having the problem, the Tornado extension is also a culprit. I had to "disable (workspace)" one by one to find it.
Try uninstalling any python extension packs you may have installed! You can then reinstall the python extension you need individually.
Chances are one of the extensions in the bundle of that extension pack is causing the issue
Click (Ctrl + K C) to comment the html.
Click (Ctrl + K U) to uncomment html.
For me, this was caused by the Sublime Babel extension. Disabling it and restarting VS Code fixed the issue: Cmd+K, Cmd+C works again, as does Cmd+/ for toggling. Also, HTML comment blocks are now correctly styled again.
You can configure the file type at the bottom right corner. you probably are on Django HTML. you can set it to HTML.
I need to convert the html.slim files in my Ruby on Rails application to html.erb. Is there any easy way to do it? I tried many options listed in Stack Overflow and other sites. But nothing worked for me. I found a converter http://slim2html.raving.systems/ and a html to slim converter http://html2slim.herokuapp.com/ . It is not of my use since it does not work the other way around. Should I have to do it manually? Please help.
I just did it using Codepen.io
Start a new pen. Choosing Slim as your HTML Markdown language. Paste in your Slim - then click the view compiled button in your HTML pane.
You'll see the straight HTML version of your markup.
You can then copy that out.
You can!
First, make sure you have already installed slim-rails. You can install it by calling gem install slim-rails.
Then write something in the input.html
Finally, you open the terminal and call:
echo `slimrb input.html` > output.html
NOTE: it is `, not ' or "
Open file output.html, that's what you looking for!
#duykhoa's answer is best and best for converting a whole file, but you can also use the inspector to see and copy the compiled HTML (CTRL+SHIFT+I in Chrome or right-click and then click on inspect to inspect an element).
slimrb -e foo.html.slim foo.html.erb
so on my ubuntu/git bash console, this is what is do it , easily
mike#mike-PORTEGE-Z30t-A:~/workspace/demo$ slimrb -e app/views/layouts/_header.html.slim app/views/layouts/_header.html.erb
and i get my new converted .erb file for .slim file.
I just started to use the trial of Sublime text 2 and was wondering if there is any function or plugin for me to convert block of HTML to javascript string ?
I have try to search but couldn't find anything. Thanks!
Sublime text doesn't perform any parsing/converting functions, it's just a very pretty and useful text editor with various syntax highlighting, and as far as I'm aware most plugins for it are either for visual styles/highlighting or version control, not converting from one thing to another.
Saying that, if you want to convert HTML to a Javascript style string try this: http://www.accessify.com/tools-and-wizards/developer-tools/html-javascript-convertor/
K. L., I am also reading this book and I gone through the same situation. I am using Notepad++ and could not find a way of doing this conversion directly from the editor. Then, I decided to download and install the vim editor (http://www.vim.org/download.php) and I made the configuration suggested by the authors on pages 73-74. It worked fine. Maybe I will try to make it work on Notepad++ in the future, but, for now, I can continue my reading. Hope this helps.
Is there any eclipse shortcut/trick/plugin/whatever that will allow me to select a section of text and surround it with an arbitrary html/xml tag when using the html editor.
Something like this textmate video
EDIT: not sure If my Eclipse setup is the same as yours, but...
I have the HTML Editor installed, and if I switch to the Java perspective, I can use Edit -> Quick Fix and then choose Surround with new element to get exactly the effect in your video. (On a Mac, the shortcut for this is ⌘1).
Hope this is helpful.
In the C++ editor, you can try Source -> Surround With... -> Configure Templates to add the tag you want.
The following works and allows for entering random/arbitrary tags:
Select the desired text that you want wrap.
Go to 'Edit > Quick Fix' or press 'Ctrl + 1'.
In the new menu that appears select 'Surround with new element'
However there is an annoyance, please upvote Bug 494169
Is there any way to close html tags if a user forgets to? E.g. when the user input is:
<b>small</b><i>test
Is there a way in Rails to automatically add the closing </i> tag, so that all the following html won't be italic?
I used .html_safe to interpret everything as html, but I would like to terminate <i> too.
Rails doesn't have any built in capability to do this however you have a couple of options:
Nokogiri - easy to install on pretty much all platforms (gem install nokogiri)
Tidy - The second post has the details to use it in linux and windows
Using nokogori you can simply do:
html = "<b>small</b><i>test"
clean = Nokogiri::HTML::DocumentFragment.parse(html).to_html
# clean = "<b>small</b><i>test</i>"
Rails can't do that to you.
You can use some template system like Haml or Slim to don't forget that.
You can do it by your own editor too.
A decent way to do this would be to feed the input to a dom parser and then have that parser output correct HTML.
Note that this isn't fool proof and if the user makes too many mistakes, the parser won't know what to do.
I'd suggest Nokogiri