Permalink
Browse files

simple objects and arrays

  • Loading branch information...
1 parent 933e1c4 commit 8ceaaf898d88d31390dc03a135155345e733ee30 @drewlesueur committed Apr 4, 2012
Showing with 21 additions and 4 deletions.
  1. +15 −0 index.html
  2. +6 −4 thumbs.js
View
@@ -163,12 +163,27 @@
</script>
<script type="text/thumbs" id="tests">
+eq. 3 otherObj. numb'
+
numbers + 1 2
3 4
' a string
+the-value 2
+eq. 3 numbers. the-value
+
+
+my-age 27
+phrase ' my age is $my-age
+eq. phrase ' my age is 27
+
eq. numbers.2 3
eq. numbers.4 ' a string
+the-value 2
+eq. 3 numbers:the-value
+
+
+
myAnimal new. animalClass 2 4
eq. myAnimal.eyes 2
eq. myAnimal.legs 4
View
@@ -297,7 +297,7 @@
convertStringNestedArgsToString(nestedArgs)
var value = rest.join(" ")
value += nestedArgs.join("\n")
- value = value.replace(/\$([\w]+)/g, function (whole, word) {
+ value = value.replace(/\$([\w\-]+)/g, function (whole, word) {
return get(word, currentScope)
})
return value;
@@ -404,7 +404,7 @@
var set = function (name, value, currentScope, opts) {
- var names = name.split(/\.|\:/)
+ var names = name.toString().split(/\.|\:/)
name = name.toLowerCase()
if (opts && opts.onlySetInCurrentScope) {
@@ -590,6 +590,8 @@
return set(args[0], args[1], fn)
}
}
+ } else if (fn.type != "fn" && (isArray(fn) || isObject(fn))) {
+ return function () { return fn[args[0]] }
} else {
var compiled = {
scope: newScope,
@@ -684,7 +686,7 @@
var get = function (name, lookupScope, opts) {
opts = opts || {}
lookupScope = lookupScope || currentScope;
-
+ name = name.toString()
if (name == "0") {
var a = 1
@@ -701,7 +703,7 @@
return name - 0
}
- var names = name.split(/\.|\:/)
+ var names = name.toString().split(/\.|\:/)
if (names[names.length - 1] == "") { //remove the last dot for function calls
names.pop();
name = name.substr(name, name.length - 1)

0 comments on commit 8ceaaf8

Please sign in to comment.