Skip to content

Commit ce41b45

Browse files
committed
Add a Context resolve() method.
1 parent 9c5b3ea commit ce41b45

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

mustang/Context.ooc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,14 @@ Context: class {
7676
}
7777

7878
resolve: func(expression: String) -> Value {
79+
offset := expression indexOf(' ')
80+
81+
// If just a simple root hash access, return value quickly
82+
if(offset == -1) {
83+
return root get(expression)
84+
}
85+
86+
//TODO: resolve chained accesses here
87+
return null
7988
}
8089
}

mustang/Node.ooc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ VariableNode: class extends TNode {
3333
init: func(=variableName) {}
3434

3535
render: func(context: Context, out: Writer) {
36-
variable := context get(variableName)
36+
variable := context resolve(variableName)
3737
if(!variable) {
3838
Exception new("Variable '%s' not found in context!" format(variableName)) throw()
3939
}
@@ -50,7 +50,7 @@ SectionNode: class extends TNode {
5050
init: func(=variableName) {}
5151

5252
render: func(context: Context, out: Writer) {
53-
variable := context get(variableName)
53+
variable := context resolve(variableName)
5454
if(!variable) {
5555
Exception new("Variable '%s' not found in context!" format(variableName)) throw()
5656
}

0 commit comments

Comments
 (0)