Sublime snippet not scoping to HTML - sublimetext3

I have the following snippet:
<snippet>
<content><![CDATA[
<label for="my-id">Name:</label>
<input type="text" id="my-name" name="my-name" value="enter your name" />
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>htmlLabel</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.html</scope>
<description>Html Label and input</description>
</snippet>
It should be scoped to HTML. It's not there when I'm in C# or Plain Text but is IS there in Markdown.

There are two ways you can fix this issue:
Change your scope to text.html.basic
Change your scope to text.html -text.html.markdown
Markdown is just a shorthand syntax for HTML. The scope for markdown is actually just text.html.markdown. You have text.html specified as your scope, so all the children of text.html are going to have access to the snippet as well.
If you want to specify a snippet for only plain HTML, you have to specify that you only want text.html.basic (the first method I showed), or you can negate certain scopes by using the - symbol (the second method I showed).
Here is a good resource where you can see all of the different types of scope for Sublime.

Related

Why are there four fields in my sublime snippet when I only have three fields defined?

I have the following snippet:
<snippet>
<content><![CDATA[
### ${1:title}
#### ${2:sub title}
${3:summary}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>qnote</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
it runs fine except when I invoke it sublime is looking for 4 tab fields instead of three, so when I'm done filling in the summary I have to hit tab again to fill the fourth field. Why is this happening and how do I change the behavior so there are only three tab fields? Thank you!
By default, snippets contain an extra hidden "field" at the end, so that you can press Tab to move the cursor to after the end of the snippet, regardless of where the last field is defined in the snippet.
Therefore, you probably want to change your snippet to remove the ${3:summary}, so that it will look like this:
<snippet>
<content><![CDATA[
### ${1:title}
#### ${2:sub title}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>qnote</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
and it will behave the way you desire.

Is there a build system for HTML based on include statements [duplicate]

Is there a plugin available for Gulp that does the same thing as Assemble does for Grunt?
I would like to run a task for Gulp that assembles HTML partials, but I cannot find a plugin. Has anyone used one and can you provide a link to it?
UPDATE: 4/21/2016
Lately, I've been using Twig.js with Gulp, along with gulp-data to render JSON in my templates. My article goes into detail. Hint: You could also use Nunjucks, Swig.js, Handlebars etc.
Article: Frontend templating with Gulp and Twig.js
Yes, you can do it with this plugin called gulp-file-include
Example :
# index.html
<!DOCTYPE html>
<html>
<body>
##include('./view.html')
##include('./var.html', {
"name": "haoxin",
"age": 12345
})
</body>
</html>
# view.html
<h1>view</h1>
# var.html
<label>##name</label>
<label>##age</label>
I made a plugin to extend html files https://www.npmjs.org/package/gulp-html-extend
master.html
<body>
<!-- ##placeholder=content -->
<!-- ##placeholder=footer -->
</body>
content.html
<!-- ##master=master.html-->
<!-- ##block=content-->
<main>
my content
</main>
<!-- ##close-->
<!-- ##block=footer-->
<footer>
my footer
</footer>
<!-- ##close-->
output
<body>
<!-- start content -->
<main>
my content
</main>
<!-- end content -->
<!-- start footer -->
<footer>
my footer
</footer>
<!-- end footer -->
</body>
It may help you.
I would like to add one more:
I use gulp-preprocess. It is great for building not only html, but also JavaScript, and can even be used in PHP.
It has simple directives:
<!-- #include filename.extension -->
<!-- #ifdef foo -->
Included html if foo is defined
<!-- #endif -->
Also #ifndef (not defined)
Variables
<!-- #echo bar -->
Or even cooler:
link
Also (as far as I can tell) unlimited sub inclusion:
<!-- I am an included file -->
<!-- #include relative/to/me/data.html -->
I have a directory tree like so:
./project root
- build/
- less/
[less,..]
- html/
- index/
Index-variables.json
[Index-partials.html,...]
Index.html
[other-build-folders,..]
- dist
[htmlfiles,...,CSS folder,...]
For each rendered html file, I have a corresponding file in the build folder and a corresponding folder for that file name. The build file listens for changes in the corresponding folder and preprocesses that data which then outputs to the matching file in the dist folder.
Since preprocess allows you to pass variables as a context object, I pass variables stored in a JSON file in the parent build folder, .e.g. index-variables.json, overwriting any global variables I've defined.
I use it with Livereload,so the upshot is that everytime I make a change in any html partial the page reloads almost instantly with the rendered html - we're talking less than 1 second. In addition to being lightening fast, preprocess seems really stable-I've never had a bug.
This is an awesome way to work.
Assemble now supports Gulp: https://github.com/assemble/assemble although at the time of posting the official Assemble website doesn't mention this, and there is very little in the way of documentation.
You can do it with a gulp plugin called gulp-handlebars-file-include
This is a very good plugin, because it dose not create or make a custom parser like, gulp-file-include, nor define a new syntax. Instead it use handlebars, therefore, it not only parse with handlebars, but also you can compile your partials files with handlebars and even include your own handlebars helpers.

Sharepoint master page asp:repeater tag

I am currently working on generating a master page for a sharepoint instance. It is however giving some issues when attempting to convert over an ASP repeater
The following works in generating a repeated text:
<!--MS:<asp:Repeater ID="TopMenu" runat="server" DataSourceID="selectedSiteMap">-->
<!--MS:<HeaderTemplate> -->
<!--ME:</HeaderTemplate> -->
<!--MS:<ItemTemplate> -->
<li>test</li>
<!--ME:</ItemTemplate> -->
<!--MS:<FooterTemplate> -->
<!--ME:</FooterTemplate> -->
<!--ME:</asp:Repeater> -->
<!--MS:<asp:SiteMapDataSource SiteMapProvider="CurrentNavigation" ShowStartingNode="false"
StartFromCurrentNode="false" StartingNodeOffset="0" StartingNodeUrl="sid:1002"
EnableViewState="true" ID="selectedSiteMap" runat="server" /> -->
However the following does not work:
<!--MS:<asp:Repeater ID="TopMenu" runat="server" DataSourceID="selectedSiteMap">-->
<!--MS:<HeaderTemplate> -->
<ul id="main_menu_ul" class="">
<!--ME:</HeaderTemplate> -->
<!--MS:<ItemTemplate> -->
<li><a href=<!--MS:"<%# Eval("Url")%>"--> class="link">
<!--MS:<%# Eval("Title")%>--></a></li>
<!--ME:</ItemTemplate> -->
<!--MS:<FooterTemplate> -->
</ul>
<!--ME:</FooterTemplate> -->
<!--ME:</asp:Repeater> -->
<!--MS:<asp:SiteMapDataSource SiteMapProvider="CurrentNavigation" ShowStartingNode="false"
StartFromCurrentNode="false" StartingNodeOffset="0" StartingNodeUrl="sid:1002"
EnableViewState="true" ID="selectedSiteMap" runat="server" /> -->
So far I have identified the issue is 2 fold:
1. the converter is does not like the fact that the opening ul and closing ul dont exactly match
2. the converter does not like the eval tags at all.
Any help anyone could give to getting this repeater to work properly would be very helpful. Thank you
The other possibility is that you are manually uploading your master page (as opposed to deploying it using a feature). The <%# Eval("Url")%> tag is seen as server-side code, and it turns out that there is a security limitation that server-side code is not allowed in customized pages - in other words, ones that are unghosted.
So if you customize a master page using SharePoint designer, the new copy exists in the content database, and this is regarded as customized.
I hit this recently - deployed an aspx master page (with a repeater control in it) using a feature, download a copy, re-upload it (with no changes) and bang - error. Code blocks not allowed in this file.
As you're putting this in an html master page, you're probably just masking the real reason for the error. You could try adding an entry to the web.config (see, for example, this blog) to specify that your master page can have code blocks.
It might because You have opened
MS: before you Eval("") but there is no closing ME: after eval tag.

generate html with translation

For a generic form checker I want to generate html <input> fields plus internationalized error messages (and default values, ...) while using templates to define which fields are in the form.
Template example:
...
<form>
${structure: make_field('email')}
</form>
Rendered template:
...
<form>
<input type="text" name="email" ... /><span>error message</span>
</form>
Problem:
The error message for each field is specified using gettext like _('error123'). Because the html string is constructed by code I have to translate() the error message myself. Therefore I have to hand in a localizer to the form checker code which I want to avoid.
Is it possible to move the rendering completely to the template engine. Maybe with macros generated in code?!

How to get document datasource in another Custom Control?

I have an xPage with this content:
<div class="lotusFrame">
<xc:layoutCommonBanner />
<xp:callback facetName="facetTitleBar" id="callbackTitleBar" />
<xc:layoutDiscrepancyPlaceBar />
<div class="lotusMain">
<div class="lotusColLeft">
<xp:callback facetName="facetColLeft" id="callbackColLeft" />
</div>
<div class="lotusColRight">
<xp:callback facetName="facetColRight" id="callbackColRight" />
</div>
<div class="lotusContent">
<xp:callback facetName="facetContent" id="callbackContent" />
</div>
</div>
<xc:layoutCommonFooter />
<xc:layoutCommonLegal />
</div>
As you can see, there are several custom controls in it composing layout. In the facetContent, there is a document with document datasource. It's the only document in the page. I need to get this document somehow in the layoutDiscrepancyPlaceBar custom control.
I found some old articles on the web with undocumented feature called currentDocument. It should be on every page with document datasource. But it doesn's work. I have Domino 8.5.2 and currentDocument seems to be no longer supported.
Can you help me out? How can I get document datasource from one custom control in another custom control. Is it even possible?
Thanks in advance, Jiří
EDIT: OK, it is still supported, but it only works in custom control, that is included inside the one with document datasource. In the case scenario above it doesn't work.
Your best option is to hand over the binding name in a custom property. (lets call it bindto. Then you bind your field to
"${#{"+compositeData.bindto+"}}"
See details here (inside the prezi)
P.S. currentDocument is documented somewhere.
You can also pass a handle on the data source directly to the custom control, as well as the name of the item to bind to on the data source. Because EL supports array syntax as well as dot syntax, this allows you to define expressions like this:
#{compositeData.dsn[compositeData.fieldName]}
(where "dsn" is the property being passed the handle on the data source, and "fieldName" is the property being passed the name of the item to bind to on that data source.)
More details on this approach can be found here.

Resources