brackets-snippets icon indicating copy to clipboard operation
brackets-snippets copied to clipboard

Javascript as snippet

Open tushar-borole opened this issue 9 years ago • 6 comments

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

tushar-borole avatar May 15 '15 17:05 tushar-borole

Hi, you can add it by yourself~ It's allowed to customize your own snippets.

chuyik avatar May 16 '15 15:05 chuyik

meaing when i trigger newdate, i should get todays date that is 16/05/2015

tushar-borole avatar May 16 '15 15:05 tushar-borole

@tushariscoolster Wow~ That's some cool stuff.. I never think about that, it's a little bit wired to run the code.

chuyik avatar May 16 '15 15:05 chuyik

Would be helpfull

tushar-borole avatar May 16 '15 15:05 tushar-borole

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:

toferj avatar Oct 27 '15 14:10 toferj

@topherj Right, Lets see who does it

tushar-borole avatar Oct 27 '15 18:10 tushar-borole