I have wrote a few methods (color map credit to mcrcon) that will help with outputting colored text using Minecraft color codes.
Usage is like
console.log(mccolor(c("3", "red Text) + c("a", "green text")));0
I’ve written aother node module to provide Google Traceur support for Node.JS
If you are not familiar with Traceur, read up on it here: http://code.google.com/p/traceur-compiler/
And the features it provides: http://code.google.com/p/traceur-compiler/wiki/LanguageFeatures
npm install traceur
then all require() calls can be traceur syntax files.
Note you can’t use Traceur syntax on the file that includes Traceur,
since this extends require() itself to go through Traceur first before
being passed to normal node require().
So, I was reading over the V8 docs yesterday and found a really neat feature in the C++ API… Interceptors.
Interceptors let you provide a global getter/setter on an object so you can get a callback for ANY property request/set without specially adding a setter/getter by name for it. This is something that I’ve found lacking in V8 JS Land to mimic PHP’s __get and __set methods, but it appears it does exists, just only on the C++ side!
So I wrote Magic this weekend, my first full 1.0.0 (1.0.1 actually, slight fix) release of a module to the public (advertised). This lets you play with a Magic Object with your own custom getters/setters (Interceptors) and do creative things with it.
Hopefully some modules that use promised based approaches will find creative ways to use these magic objects and create useful things out of it!
Download/Instructions @ GitHub0
Just wanted to update on what i’m currently working on.
Nova is pretty much in a releasable state except that I ran into another idea to do at work and it was something I could use asap at work so I began work on it.
I’m creating an alternative package installer for NPM, with a few key differences:
- No symlink hell: Maybe no symlinks at all. I’m designing it to install a package from NPM without any symlinks (i think I may make it so that if you link to a non JS file as a module it will symlink, but undecided yet as that feature doesn’t even work on default NPM, so possibly wont do any symlinking)
- Lightweight packages: A module package will not include tons of references to other dependencies in its folder. It will simply be the folder that was published to npm (usually the project on github)
- Per Project basis: Modules will be installed to a specific projects libs folder and not on a global level. Letting you manage the packers needed for your specific project, and no needing to worry about file permissions, and no need to worry about deployment ensuring your server has all the needed npm packages installed at the correct version.
The recursive symlinks of npm destroy some IDE’s and overall makes a hard to figure out folder structure. They also do not play as nice for windows, causing it confusion.
So that was the main reason for making this. As I could no longer work on my project due to the symlinks (yes it’s an IDE bug that should be fixed, but the linking isn’t really necessary, at least not recursively)
Also, the idea of global modules does not serve well for packaging modules into a projects version control. Trying to configure npm to install to a projects folder instead of global was a nightmare.
So barenpm is designed to be a tool for people who want to bundle packages as part of their project and included in a much leaner fashion.
I also am writing this in order to show to Isaacs so he may take some ideas from this implementation of the install method and hopefully get NPM to provide these features and not need symlinks. That is my ultimate goal,
but I needed the solution now and could not wait for NPM to officially support these ideas.
If you want to check out the current code, hit it up on my github http://github.com/aikar/barenpm
It’s not done, but it’s getting close.
I will finish up Nova documentation and do a proper release afterwards.0
One big annoyance with template engines these days for me is the idea that the syntax has to be some special unique format, in which no IDE or editor will ever support out of the box unless it gets extremely huge like Smarty. That to me is very annoying, as you lose all the benefits syntax highlighting and other features your editor can provide.
Wait you say, “functions and logic inside a template engine?! That goes against the point of a template engine!”
No, It doesn’t. Some random guy on the Internet made a blog post saying HE thinks you shouldn’t have any logic done in a template and it spread, and now everyone thinks that its bad to have logic in a template.
But no, it’s not. You’re end goal is to make use of the tools available to you, and accomplish your goals cleanly, efficiently, and as quickly as possible.
If you only have a flat head screw driver, which fits into the size of a Phillip head screw, would you run to the store to buy a Phillip head screwdriver, or would you use the Flathead and just unscrew the screw?
A tool or library should not necessarily restrict you from doing things. It should be you, the user of said library, who decides the best practices and implementation for your project. If you want to keep all logic out of a template, then do it. If you feel having logic in a template makes your task easier, then do it.
This concept that the tool should dictate what you use it for needs to go.
Nova will be flexible, and not restrictive. So you can build your template however you want. You give it data in its expected fashion, and it will act on that. It’s not going to spank you for using logic in your template. (Although if you’re into that kind of thing I can write a special version for you for a price… :))
Here is an example (very basic) template for Nova:
would work just as fine. Again it’s YOUR choice for standards.
Now. Nova caches templates on load to pure HTML so this syntax isnt parsed EVERY time the template is rendered. But static templates are no fun of course… we need to be able to render dynamic content!
Well, notice that nova variable I didn’t use in the example? That has helper functions! One of those functions is nova.onRender
This function will let you specify a callback function to execute anytime the template is rendered. Note the object notation format is parsed and processed on COMPILE time, ie the very first request, then on render the onRender functions are called to fill in dynamic data.
So how do you use them? take the following template above and lets replace the [‘My content’] with:
So when you call template.render() in your application, you pass it 2 arguments, with the first (optionally) being render variables.
These are variables you can build in your applications logic before rendering to the client, then pass it to template to use just like any other template engine.
Also, because templates can render Asynchronously.
Notice in the above example, we give a different call to render based on if username was set or not.
Firstly to explain render, anything passed to this function will be the ‘answer’ to what content should fill the onRender spot. So if my username was Aikar, I would see:
<div id="content"> <span>Greetings Aikar</span></div>
Also notice I was able to still use the Nova style syntax of the template, and did not have to type raw HTML!
Nova is extremely flexible, and will give you the tools you need to write fun templates.
Also, again they are Asynchronous. The template runs all onRender async, and will wait for all of them to ‘answer back’
So say you wanted to do some async operation like a database query (again, do what you want with your templates, it’s your choice), you would do something like this:
Check the Nova docs when its released for more helpers such as partial/include support!0
I’ve done a lot for communities in Final Fantasy XI and other games, and been a good community leader, but now I’m finally ready to release a library to open source! (I’ve worked on projects to release but never finished…)
Over the past week or two I’ve been working on a new Template Engine for Node. Why another you ask? Well cause I felt like it mainly, and wanted to do something interesting.
So now I am working on Nova. As you may know (by either knowing me or reading my blog), I am working on a space game, so I’ve chosen the space theme as a naming scheme for my modules I write. I am wanting to write a lot of the modules Starlis will use, and then release them to the public.
I already have plans to do a MongoDB wrapper similar to Mongoose as my next library, named Meteor. I also have some code I’ve already written a base for message framing and sending over streams, and plan to do an RPC layer on top of, using the MessagePack format for serialization which is a lot better in performance than JSON. It will use pgriess’s node-msgpack library which I’ve forked and added support for Node 0.3.x.
I also plan to add a CSS layer onto Nova shortly after release, providing the same syntax for CSS.
Read my next blog post for details on Nova!
Look forward to my modules soon, First being Nova, then Meteor and Wormhole sometime after.0