(and the oddities of number evaluation in JavaScript)
Type conversion, typecasting, and coercion are different ways of, implicitly or explicitly, changing an entity of one data type into another. [--wikipedia][wikipedia]
############################################################################################################ | |
### % [ title ] ( src ) ### | |
video_matcher = /^%\[([^\]]*)\]\s*\(([^)]+)\)/ | |
#----------------------------------------------------------------------------------------------------------- | |
parse_video = ( state, silent ) -> | |
return false if state.src[ state.pos ] isnt '%' | |
match = video_matcher.exec state.src[ state[ 'pos' ] .. ] | |
return false unless match? | |
unless silent |
{ | |
"bold_folder_labels": false, | |
"close_windows_when_empty": false, | |
"color_scheme": "Packages/Monokai Extended/Monokai Extended.tmTheme", | |
"default_line_ending": "unix", | |
"detect_indentation": false, | |
"draw_indent_guides": true, | |
"draw_white_space": "selection", | |
"ensure_newline_at_eof_on_save": false, | |
"file_exclude_patterns": [ |
Handlebars.registerHelper('foo', function (name, context, options) { | |
var fn = Handlebars.compile(Handlebars.partials[name]); | |
var frame = Handlebars.createFrame(context.data); | |
for (var prop in options.hash) { | |
frame[prop] = options.hash[prop]; | |
} | |
var template = fn(context, {data: frame}); | |
return new Handlebars.SafeString(template); |
This example makes use of
strings.parser()
andstrings.process()
to dynamically generate permalinks from local file paths.
Before we get started, it's important to note that although we're going to use three different methods to accomplish our goal, .propstring()
, .parser()
, and .template()
, we can accomplish the same thing with one method: .process()
. But, the point of this tutorial is to demonstrate how to create reusable templates and parsers, and as a result you'll learn how .process()
works along the way.
Now, on to the subject of this tutorial!
# I'm only using a few fields here to demonstrate how this works | |
# Site theme | |
theme: slides | |
# Assets | |
# The assets path is based on the theme, | |
# the other paths can build on the assets path | |
assets: assets/<%= site.theme %> | |
images: <%= site.assets %>/images |