brackets-snippets
brackets-snippets copied to clipboard
Javascript as snippet
Should able to added javascript as snippet
for example
trigger key as "newdate"
and text will be javascript returned value like
today = new Date(); var dateString = today.format("dd-m-yy"); return dateString
Hi, you can add it by yourself~ It's allowed to customize your own snippets.
meaing when i trigger newdate, i should get todays date that is 16/05/2015
@tushariscoolster Wow~ That's some cool stuff.. I never think about that, it's a little bit wired to run the code.
Would be helpfull
I'm moving to Brackets from ColdFusion Builder (an Eclipse based IDE), and the Snippets feature in there, allows for dynamic default values. Is that what you guys are discussing here?
For instance the ability to have a snippet that not only puts the pre-defined text in place, but also populates something like the current date. I haven't looked at the code under the hood yet, but maybe the snippet would look something like this:
- trigger: newjs
description: New JavaScript Skeleton
scope: javascript
text: |
/**
* @author ${1:author} <${2:email}>
* @namespace $p
* @createDate ${new Date();}
*
*/
// create a namespace for this code
var $p = $p || {};
Maybe there should be some built-in constants that we could use inside of snippets that would make these kinds of things easier for example:
${DATE}
${DAYOFMONTH}
${MONTH}
${YEAR}
${TIME}
${HOUR}
${MINUTE}
${SECOND}
If I have time I may look into contributing this kind of functionality, but if you can beat me to it that'd be great. :grinning:
@topherj Right, Lets see who does it