change to !json and !code for the include macros

improve_associations
Chris Anderson 2009-01-08 10:00:36 -08:00
parent 5d3e684c6a
commit 3c789ab317
3 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,6 @@
function(doc, req) {
// !include lib.templates
// !require lib.helpers.template
// !code lib.helpers.template
// !json lib.templates
respondWith(req, {
html : function() {

View File

@ -1,6 +1,6 @@
// an example map function, emits the doc id
// and the list of keys it contains
// !require lib.helpers.math
// !code lib.helpers.math
function(doc) {
var k, keys = []

View File

@ -172,7 +172,7 @@ module CouchRest
# process requires
def process_require(f_string)
f_string.gsub /(\/\/|#)\ ?!require (.*)/ do
f_string.gsub /(\/\/|#)\ ?!code (.*)/ do
fields = $2.split('.')
library = @doc
fields.each do |field|
@ -188,7 +188,7 @@ module CouchRest
# process includes
included = {}
f_string.gsub /(\/\/|#)\ ?!include (.*)/ do
f_string.gsub /(\/\/|#)\ ?!json (.*)/ do
fields = $2.split('.')
library = @doc
include_to = included
@ -214,7 +214,8 @@ module CouchRest
varstrings = included.collect do |k, v|
"var #{k} = #{v.to_json};"
end
f_string.sub /(\/\/|#)\ ?!include (.*)/, varstrings.join("\n")
# just replace the first instance of the macro
f_string.sub /(\/\/|#)\ ?!json (.*)/, varstrings.join("\n")
end
rval