change to !json and !code for the include macros
This commit is contained in:
parent
5d3e684c6a
commit
3c789ab317
|
@ -1,7 +1,6 @@
|
||||||
function(doc, req) {
|
function(doc, req) {
|
||||||
// !include lib.templates
|
// !code lib.helpers.template
|
||||||
|
// !json lib.templates
|
||||||
// !require lib.helpers.template
|
|
||||||
|
|
||||||
respondWith(req, {
|
respondWith(req, {
|
||||||
html : function() {
|
html : function() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// an example map function, emits the doc id
|
// an example map function, emits the doc id
|
||||||
// and the list of keys it contains
|
// and the list of keys it contains
|
||||||
// !require lib.helpers.math
|
// !code lib.helpers.math
|
||||||
|
|
||||||
function(doc) {
|
function(doc) {
|
||||||
var k, keys = []
|
var k, keys = []
|
||||||
|
|
|
@ -172,7 +172,7 @@ module CouchRest
|
||||||
|
|
||||||
# process requires
|
# process requires
|
||||||
def process_require(f_string)
|
def process_require(f_string)
|
||||||
f_string.gsub /(\/\/|#)\ ?!require (.*)/ do
|
f_string.gsub /(\/\/|#)\ ?!code (.*)/ do
|
||||||
fields = $2.split('.')
|
fields = $2.split('.')
|
||||||
library = @doc
|
library = @doc
|
||||||
fields.each do |field|
|
fields.each do |field|
|
||||||
|
@ -188,7 +188,7 @@ module CouchRest
|
||||||
|
|
||||||
# process includes
|
# process includes
|
||||||
included = {}
|
included = {}
|
||||||
f_string.gsub /(\/\/|#)\ ?!include (.*)/ do
|
f_string.gsub /(\/\/|#)\ ?!json (.*)/ do
|
||||||
fields = $2.split('.')
|
fields = $2.split('.')
|
||||||
library = @doc
|
library = @doc
|
||||||
include_to = included
|
include_to = included
|
||||||
|
@ -214,7 +214,8 @@ module CouchRest
|
||||||
varstrings = included.collect do |k, v|
|
varstrings = included.collect do |k, v|
|
||||||
"var #{k} = #{v.to_json};"
|
"var #{k} = #{v.to_json};"
|
||||||
end
|
end
|
||||||
f_string.sub /(\/\/|#)\ ?!include (.*)/, varstrings.join("\n")
|
# just replace the first instance of the macro
|
||||||
|
f_string.sub /(\/\/|#)\ ?!json (.*)/, varstrings.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
rval
|
rval
|
||||||
|
|
Loading…
Reference in a new issue