What scope for html.erb in Sublime Text? - html

I'm writing a snippet for html.erb files,
but I can't understead what should I write in scope tag.
When I press ctrl+shift+alt+p it shows to me "text.html.ruby text.html.basic"
html.erb
<p>test</p>
<%= 'test' %>
The snippet
<snippet>
<content><![CDATA[test]]></content>
<tabTrigger>test</tabTrigger>
<scope>text.html.ruby</scope>
</snippet>
or
<snippet>
<content><![CDATA[test]]></content>
<tabTrigger>test</tabTrigger>
<scope>text.html.basic</scope>
</snippet>
Doesn't work but it's all right with the snippet cuz when I change the scope to "source.ruby" all is working fine.
P.S correct my english.

Correct tag for erb is:
<scope>text.html.ruby</scope>
You problem in content section, because tabTrigger "test" will be replaced by same value "test". There should be something like this:
<snippet>
<content><![CDATA[<%= ${1:test} %>]]></content>
<tabTrigger>test</tabTrigger>
<scope>text.html.ruby</scope>
</snippet>

Related

Rails atom_feed: How to add HTML tags like <h1> to the feed content?

I want to structure the content of my Atom feed using headings:
atom_feed do |feed|
feed.title "#{Page.model_name.human(count: :other)} - #{t('app.name')}"
feed.updated(#pages[0].created_at) if #pages.length > 0
#pages.each do |page|
feed.entry(page) do |entry|
entry.title(page.title)
entry.content(type: 'html') do |html|
html.h1 t('.position_in_hierarchy')
html.p page.ancestors.reverse.map(&:title).join ': '
html.h1 Page.human_attribute_name :lead
html.div markdown page.lead
html.h1 Page.human_attribute_name :content
html.div markdown page.content
end
end
end
end
For each of my pages, this results in the following generated XML:
<entry>
<id>tag:localhost,2005:PageDecorator/1</id>
<published>2017-02-24T18:11:26+01:00</published>
<updated>2017-04-05T09:58:42+02:00</updated>
<link rel="alternate" type="text/html" href="http://localhost:3001/en/pages/1"/>
<title>Preparation</title>
<content type="html">
<h1>Position in page hierarchy</h1>
<p>Preparation</p>
<h1>Lead</h1>
<div><p>This the lead.</p></div>
<h1>Content</h1>
<div><p>This is some content!</p>
<h2 id="with-a-heading">With a heading</h2>
<p><a href="http://www.example.com">And a link!</a></p></div>
<h1>Notice about Atom feed</h1>
<p>Your feed reader has downloaded version 14 of the current page, which was current at April 05, 2017 09:58. Meanwhile there could be an updated version of the page available online. Visit the original page to see the most current version!</p>
</content>
</entry>
As you can see, the html.h1 calls are rendered as plain <h1>. But interestingly, my feed reader Vienna doesn't display them! More interestingly, the content of html.div, which is markdown rendered by my custom markdown method, is html escaped... and this stuff is rendered by Vienna!
The markdown method itself escapes HTML:
def markdown(string)
PandocRuby.convert(string, to: :html).html_safe
end
So I'm pretty unsure now what to do to make my other HTML markup work in Vienna, too.
As Kris pointed out in his comment, the content needs to be escaped: https://validator.w3.org/feed/docs/atom.html#text
The easiest thing to do this is just rendering a partial like this:
entry.content(render(page), type: 'html')
This will render _page.atom.slim (or .erb or whatever) and automatically escape the HTML.

Add comment after html closing tab with sublime text

I want to know if is possible to add comments to existing html closing tags, for example:
<div class="container">
Content
</div>
And I want to format it to be like this:
<div class="container">
Content
</div> <!-- /.container -->
With emmet (.container>{Content}) I will have to rewrite all my code to get the comments, so it's possible to add closing comment with sublime text 3 to an existing html code instead to rewrite it again using emmet?
I'm not sure I understand the end of your post regarding emmet, but adding a comment after the HTML closing tag should be fine as any comments in an HTML file are ignored by the browser regardless of where they are placed.
Hope this helps.

How to add snippet menu onTrigger sublime text 2

I try to make in my snippet when you trigger it gives you the same "dropdown" as auto complete does.
My currently snippet looks like:
<snippet>
<content>
<![CDATA[
Somehow to make an menu..
]]>
</content>
<tabTrigger>Trigger</tabTrigger>
</snippet>

code or pre element isn't working perfectly on Bootstrap

I am creating a landing page for myself with Twitter Bootstrap framework and I want to show some code on my landing page and that's why I am writing my code into <code></code> or <pr></pre> this elements but it's not showing. I put my code like below:
<code>
<command type="?">Click Me!</command>
</code>
or
<pre>
<command type="?">Click Me!</command>
</pre>
But, Twitter Bootstrap is only showing to me "Click Me!" word. He don't show me the whole code into the <code> or <pre> elements.
How may I fix this?
You still have to replace the < and > characters with < and >, respectively, or they will be interpreted as HTML:
<pre>
<command type="?"> Click Me! </command>
</pre>

How to embedd cgi in html

I have no problem executing a cgi file under the normal url like this:
http://www.myhost.com/mydir/cgi-bin/test.cgi
However when I tried to embedd it into HTML file (called index.html) like this:
<HTML>
<BODY>
<P>Here's the output from my program:
<FORM ACTION="/var/www/mydir/cgi-bin/test.cgi" METHOD=POST>
<!-- This doesn't work also -->
<!-- FORM ACTION="cgi-bin/test.cgi" METHOD=POST-->
</FORM>
</P>
</BODY>
</HTML>
The CGI doesn't get executed when I do:
http://www.myhost.com/mydir/index.html
The CGI file (test.cgi) simply looks like this:
#!/usr/bin/perl -wT
use CGI::Carp qw(fatalsToBrowser);
print "Test cgi!\n";
What's the right way to do it?
The problem is the path you are providing in the action property of the form.
You need to change it to be a path relative to the current document. (index.html)
From your example, it looks like this would be cgi-bin/test.cgi
There isn't a good way to do this in HTML. It is a job better suited for SSI using an exec or virtual directive.
Use templates. It's bad idea to mix different code together. Even JS and CSS are separated from (X)HTML for readability and maintainability.
Have you tried using an iframe:
<HTML>
<BODY>
<P>Here's the output from my program:
<iframe src="http://www.myhost.com/mydir/cgi-bin/test.cgi" />
</P>
</BODY>
</HTML>