Dynamic snippet text in snippets.cson


#1

I’d like to dynamically include the current date/time in a snippet for markdown.
The snippet would look something like this.

'.source.gfm':
  'Header':
    'prefix': 'header'
    'body': 'My name - `Date.today.strftime('%D')`'

which would print:

My name - 4/2/14

Date.today.strftime(’%D’) is Ruby, the equivalent js a little longer (unless there’s an easier way):

var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
console.log(curr_month + "/" + curr_date + "/" + curr_year);

Thoughts?


Snippets that use env variables or local variables
#2

Interesting idea. Could you open up an issue on the https://github.com/atom/snippets repo?


#4

I just created an issue on github.