Permalink
Browse files

compile the views on an intelligent basis

  • Loading branch information...
1 parent 9381757 commit 016194f754ed27893f1bb0a6676150b275b0b64f @jneen committed Jan 12, 2011
Showing with 16 additions and 4 deletions.
  1. +16 −4 lib/view.sh
View
@@ -1,8 +1,20 @@
#!/bin/bash
esh=$(readlink -f $BALLS_LIB/../bin/esh)
render::esh() {
- local src="$($esh $BALLS_VIEWS/$1)"
- (
- eval "$src"
- )
+ local view="$BALLS_VIEWS/$1"
+ local compiled="$(esh::compile "$view")"
+
+ # source it in a subshell so it gets our variables
+ ( . "$compiled" )
+}
+
+esh::compile() {
+ local view="$1"
+ local compiled_fname="$view.o"
+
+ if [[ ! -f "$compiled_fname" ]] || [[ "$view" -nt "$compiled_fname" ]]; then
+ $esh "$view" > "$compiled_fname"
+ fi
+
+ echo "$compiled_fname"
}

0 comments on commit 016194f

Please sign in to comment.