Can I use .handlebars files with Meteor? - meteor

For the sake of clarity, and because SublimeText isn't bright enough to know the difference between lots of different flavors of ".html", I thought about using .handlebars as the extension to my handlebars-templated files. Meteor seems to only accept files with with .html extension, and I'm wondering if there's a way I can get it to accept .handlebars files too. Thanks

This may be more complicated than you'd like, but one way you can accomplish this is by making your own version of the templating package.
make a copy of the subtree,
rename the package,
edit plugin/compile-templates.js and at the bottom in the call to registerSourceHandler, replace "html" with "handlebars".
put your new package into your project's packages and add it using meteor add yourpackagename.

The comment left by Hubert OG was the simplest solution. Use .handlebars.html files. The SublimeText plugin for handlebars now recognizes that file extension too.

Related

How do I generate .d.ts typings from Flow code?

I have enabled Flow on a JavaScript project I am developing. Since I am putting in the effort to providing type annotations, I would really like to generate *.d.ts files so the broader TypeScript community can also have type information.
How can I generate *.d.ts type definition files from Flow-annotated JavaScript?
I searched for the available tools. I found the following.
The first one is the most up to date one. It can convert the whole Flow code to TypeScript. I have used it personally, and it works like a charm.
https://github.com/Khan/flow-to-ts
Other ones:
https://github.com/Kiikurage/babel-plugin-flow-to-typescript
https://github.com/burnnat/flow-to-dts
https://github.com/bcherny/flow-to-typescript
https://github.com/yuya-takeyama/flow2dts

Handlebars.js recursive precompilation

Question, i'm trying to precompile my .handlebars files to templates.js.
So far it's working for all files in source dir, but not for files in a subdirectory (where i keep the partials).
The command i'm using:
handlebars -m resources/views/handlebars/> resources/assets/js/handlebars/templates.js
How can i make this recursive, so that it iterates all directories?
The solution was very simple:
handlebars resources/views/handlebars/ -f public/js/templates.js
Note, this also precompiles all partials that reside in a subdir.
To make these accessible in templates, add this line in beginning of your code:
Handlebars.partials = Handlebars.templates;
Since partials are also templates, this seems like a harmless solution, albeit not the most memory friendly one. If anyone has a suggestion for this..?
Now i want to delve into precompiling custom helpers... documentation is not very clear about that. I'll properly concat these with elixir.

How do I use Atom's linter-jshint when code is split up across multiple files?

I'm writing a single-page JavaScript application and I'm using Atom as my text-editor. (It's an Electron application, but that's besides the point.)
I'm also using the linter-jshint plugin for Atom. This is great, as it shows immediately in the text-editor when I make a typo in a variable, among other useful things.
Lately, my app has been getting very long. Naturally, I want to try and split it up across multiple files. After doing some research on StackOverflow, I've determined that I can use Grunt to automatically concatenate JavaScript files together. This is great because I don't have to refactor my code - I can just copy paste my existing functions into separate files. Easy!
However, once I do this, Atom fills up with warnings and errors from JSHint, because it can't find variables and functions that are located in the other files!
Now, I could just abandon the JHint plugin in Atom altogether and use the JSHint plugin for Grunt after the concatenation has already occured. But that sucks! I want the code that I'm going to be writing to be checked on the fly like a real IDE.
Is there a way to tell Atom/JSHint to assume that a bunch of JavaScript files will all be concatenated together? Or am I just approaching this problem completely wrong?
You can split your electron application with Node Common Modules, and use require('./state.js'); within your application.
Although I don't use Atom, that should allow for it to understand how you're using your variables and functions in other files.
Also this should eliminate your need for concatenation as the single-page app will have all it's dependencies accounted for.

CSS-precompiler LESS and/or SASS

Is there a way to avoid working with the command-line installing and using LESS??
There are several offers for GUIs for the compiling-phase, but I did not find a way for the Installation-Phase.
I have been working in the IT-business for so many decades (more in the mainframe and midrange area and as a project-manager and programmer in the application development) and could by now avoid to go as far down to the command-line-world.
I did develop quite fine Websites using HTML5 and CSS3 and doint this I felt a desire for all that, what LESS and/or SASS are offering and the Syntax and logics dont look difficult to handle. But I fail in the first step of just installing it.
The LESS-Website offers command-lines to key in. But I am not sure, if this will be all I have to key in, but only the significant line to be embedded in a sequence of other commands very familiar to all those working at this Level.
How do I e.g. define the place to store the Installation and to refer to in the href in the link-Statement of my html-file .... ??
Thanks
Gerhard (from Vienna/Austria, living in Trier, Germany)
Less is a CSS pre-processor. if you are include less.js in you html page
You can use less directly in to your html page.
Other ways you can use less compiler
Kola this is an open source application it will help you to compile less to css
Your Topics are clear to me. I even downloaded Koala already and I have no Problem in including less.js in my html. And I have read Bass Jobsens book about the Syntax, which does not seem to raise great Problems to me.
But before working with it, I will have to download LESS -what I have done from the Less-Website to the Folder of my choice. My Problem is the next necessary step: To install this downloaded program. There is no install.exe or something like that. The book as well as the info in the less-Website tell me to key some crpytic commands into the command-line.

OneJar Expand with (or without) sbt-onejar

Is there a way to tell the sbt-onejar SBT plugin to produce a JAR in such way that the .class files of my project are in "expanded" form and not under lib/myproject.jar?
Alternatively, is it possible to tell sbt-onejar to produce a JAR that, when it's loaded, it actually unpacks/expands the nested JARs into a temporary folder and loads them from there, so that things like getResource(...) return paths to physical files as opposed to jar:file:... URLs?
Alternativel, I'd also happy with any vanilla OneJar solutions that help me produce a fat JAR wherein my own .class files would be directly under the fat JAR as opposed to under lib/myproject.jar.
I'm asking because Jetty does not seem to be able to load JSP files from inside of nested JAR files. There does seem to be a workaround by using a custom resource loader (see http://dev.eclipse.org/mhonarc/lists/jetty-users/msg01174.html for a report of the same problem and the workaround) but I don't seem to be able to get my servlets to actually use the overridden getResource method provided in the workaround.
After having read sbt-onejar's source code:
packageOptions in oneJar ++=
Seq(sbt.Package.ManifestAttributes(
new java.util.jar.Attributes.Name("One-Jar-Expand") -> "some-file.txt"))
However, I've realized using OneJar with Jetty is quite a problematic beast due to how Jetty loads JSP files—doesn't seem to work with nested JARs—so I'm looking into alternatives now.
EDIT: I've found https://github.com/xerial/sbt-pack and it seems to achieve the same effect as OneJar with the difference of being standard and thus free of problems, much faster, more customizable, and allows defining of convenient custom program entry points.

Resources