Browse Source

Fly->PlainModel; read:do: in model, path parsing.

Herbert Vojčík 12 years ago
parent
commit
4b9825caab
7 changed files with 187 additions and 137 deletions
  1. 2 3
      demo.html
  2. 4 17
      js/Trapped-Demo.deploy.js
  3. 8 26
      js/Trapped-Demo.js
  4. 63 25
      js/Trapped-Frontend.deploy.js
  5. 78 35
      js/Trapped-Frontend.js
  6. 4 13
      st/Trapped-Demo.st
  7. 28 18
      st/Trapped-Frontend.st

+ 2 - 3
demo.html

@@ -1,6 +1,6 @@
 <html>
 <head>
-    <title data-trap="NameView:Name"></title>
+    <title data-trap="NameView: App title"></title>
     <script src="/vendor/amber/js/amber.js"></script>
 </head>
 <body>
@@ -11,14 +11,13 @@
         ready:function () {
             $(function() {
                 smalltalk.Browser._openOn_(smalltalk.App);
-                smalltalk.Name._start();
                 smalltalk.App._start();
                 smalltalk.Trapped._start();
             });
         }
     });
 </script>
-<div data-trap="AppView:App">
+<div data-trap="AppView: App">
 </div>
 </body>
 </html>

+ 4 - 17
js/Trapped-Demo.deploy.js

@@ -1,12 +1,13 @@
 smalltalk.addPackage('Trapped-Demo', {});
-smalltalk.addClass('App', smalltalk.TrappedFly, [], 'Trapped-Demo');
+smalltalk.addClass('App', smalltalk.TrappedPlainModel, [], 'Trapped-Demo');
 smalltalk.addMethod(
 "_initialize",
 smalltalk.method({
 selector: "initialize",
 fn: function (){
 var self=this;
-smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("items","__minus_gt",[["hello", "world"]])])]);
+smalltalk.send(self,"_initialize",[],smalltalk.TrappedPlainModel);
+smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("items","__minus_gt",[["hello", "world"]]),smalltalk.send("title","__minus_gt",["To-Do List"])])]);
 return self}
 }),
 smalltalk.App);
@@ -20,7 +21,7 @@ smalltalk.method({
 selector: "renderOn:",
 fn: function (html){
 var self=this;
-smalltalk.send(html,"_h2_",["To-Do List"]);
+smalltalk.send(smalltalk.send(html,"_h2",[]),"_trapShow_",[["title"]]);
 smalltalk.send(smalltalk.send(html,"_p",[]),"_trapShow_",[["items"]]);
 return self}
 }),
@@ -28,20 +29,6 @@ smalltalk.AppView);
 
 
 
-smalltalk.addClass('Name', smalltalk.TrappedFly, [], 'Trapped-Demo');
-smalltalk.addMethod(
-"_initialize",
-smalltalk.method({
-selector: "initialize",
-fn: function (){
-var self=this;
-smalltalk.send(self,"_payload_",["To-Do List"]);
-return self}
-}),
-smalltalk.Name);
-
-
-
 smalltalk.addClass('NameView', smalltalk.Widget, [], 'Trapped-Demo');
 smalltalk.addMethod(
 "_renderOn_",

+ 8 - 26
js/Trapped-Demo.js

@@ -1,5 +1,5 @@
 smalltalk.addPackage('Trapped-Demo', {});
-smalltalk.addClass('App', smalltalk.TrappedFly, [], 'Trapped-Demo');
+smalltalk.addClass('App', smalltalk.TrappedPlainModel, [], 'Trapped-Demo');
 smalltalk.addMethod(
 "_initialize",
 smalltalk.method({
@@ -7,11 +7,12 @@ selector: "initialize",
 category: 'initialization',
 fn: function (){
 var self=this;
-smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("items","__minus_gt",[["hello", "world"]])])]);
+smalltalk.send(self,"_initialize",[],smalltalk.TrappedPlainModel);
+smalltalk.send(self,"_payload_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("items","__minus_gt",[["hello", "world"]]),smalltalk.send("title","__minus_gt",["To-Do List"])])]);
 return self},
 args: [],
-source: "initialize\x0a\x09self payload: #{'items'->#('hello' 'world')}",
-messageSends: ["payload:", "->"],
+source: "initialize\x0a\x09super initialize.\x0a\x09self payload: #{'items'->#('hello' 'world'). 'title' -> 'To-Do List'}",
+messageSends: ["initialize", "payload:", "->"],
 referencedClasses: []
 }),
 smalltalk.App);
@@ -26,37 +27,18 @@ selector: "renderOn:",
 category: 'rendering',
 fn: function (html){
 var self=this;
-smalltalk.send(html,"_h2_",["To-Do List"]);
+smalltalk.send(smalltalk.send(html,"_h2",[]),"_trapShow_",[["title"]]);
 smalltalk.send(smalltalk.send(html,"_p",[]),"_trapShow_",[["items"]]);
 return self},
 args: ["html"],
-source: "renderOn: html\x0a\x09html h2: 'To-Do List'.\x0a\x09html p trapShow: #('items')",
-messageSends: ["h2:", "trapShow:", "p"],
+source: "renderOn: html\x0a\x09html h2 trapShow: #('title').\x0a\x09html p trapShow: #('items')",
+messageSends: ["trapShow:", "h2", "p"],
 referencedClasses: []
 }),
 smalltalk.AppView);
 
 
 
-smalltalk.addClass('Name', smalltalk.TrappedFly, [], 'Trapped-Demo');
-smalltalk.addMethod(
-"_initialize",
-smalltalk.method({
-selector: "initialize",
-category: 'initialization',
-fn: function (){
-var self=this;
-smalltalk.send(self,"_payload_",["To-Do List"]);
-return self},
-args: [],
-source: "initialize\x0a\x09self payload: 'To-Do List'",
-messageSends: ["payload:"],
-referencedClasses: []
-}),
-smalltalk.Name);
-
-
-
 smalltalk.addClass('NameView', smalltalk.Widget, [], 'Trapped-Demo');
 smalltalk.addMethod(
 "_renderOn_",

+ 63 - 25
js/Trapped-Frontend.deploy.js

@@ -1,5 +1,5 @@
 smalltalk.addPackage('Trapped-Frontend', {});
-smalltalk.addClass('TrappedFly', smalltalk.Object, ['payload'], 'Trapped-Frontend');
+smalltalk.addClass('TrappedPlainModel', smalltalk.Object, ['payload'], 'Trapped-Frontend');
 smalltalk.addMethod(
 "_name",
 smalltalk.method({
@@ -11,7 +11,7 @@ $1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
 return $1;
 }
 }),
-smalltalk.TrappedFly);
+smalltalk.TrappedPlainModel);
 
 smalltalk.addMethod(
 "_payload",
@@ -22,7 +22,7 @@ var self=this;
 return self["@payload"];
 }
 }),
-smalltalk.TrappedFly);
+smalltalk.TrappedPlainModel);
 
 smalltalk.addMethod(
 "_payload_",
@@ -33,7 +33,22 @@ var self=this;
 self["@payload"]=anObject;
 return self}
 }),
-smalltalk.TrappedFly);
+smalltalk.TrappedPlainModel);
+
+smalltalk.addMethod(
+"_read_do_",
+smalltalk.method({
+selector: "read:do:",
+fn: function (path,aBlock){
+var self=this;
+var data;
+data=smalltalk.send(path,"_inject_into_",[smalltalk.send(self,"_payload",[]),(function(soFar,segment){
+return smalltalk.send(soFar,"_at_",[segment]);
+})]);
+smalltalk.send(aBlock,"_value_",[data]);
+return self}
+}),
+smalltalk.TrappedPlainModel);
 
 smalltalk.addMethod(
 "_start",
@@ -44,7 +59,7 @@ var self=this;
 smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_register_name_",[self,smalltalk.send(self,"_name",[])]);
 return self}
 }),
-smalltalk.TrappedFly);
+smalltalk.TrappedPlainModel);
 
 
 smalltalk.addMethod(
@@ -56,7 +71,7 @@ var self=this;
 smalltalk.send(smalltalk.send(self,"_new",[]),"_start",[]);
 return self}
 }),
-smalltalk.TrappedFly.klass);
+smalltalk.TrappedPlainModel.klass);
 
 
 smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
@@ -131,21 +146,6 @@ return self}
 }),
 smalltalk.Trapped);
 
-smalltalk.addMethod(
-"_read_do_",
-smalltalk.method({
-selector: "read:do:",
-fn: function (path,aBlock){
-var self=this;
-var model;
-model=smalltalk.send(smalltalk.send(path,"_allButFirst",[]),"_inject_into_",[smalltalk.send(smalltalk.send(self,"_byName_",[smalltalk.send(path,"_first",[])]),"_payload",[]),(function(soFar,segment){
-return smalltalk.send(soFar,"_at_",[segment]);
-})]);
-smalltalk.send(aBlock,"_value_",[model]);
-return self}
-}),
-smalltalk.Trapped);
-
 smalltalk.addMethod(
 "_register_name_",
 smalltalk.method({
@@ -169,6 +169,7 @@ var jq;
 var viewName;
 var modelName;
 var tokens;
+var path;
 jq=smalltalk.send(elem,"_asJQuery",[]);
 jq;
 trap=smalltalk.send(jq,"_attr_",["data-trap"]);
@@ -177,9 +178,15 @@ tokens=smalltalk.send(trap,"_tokenize_",[":"]);
 tokens;
 viewName=smalltalk.send(tokens,"_first",[]);
 viewName;
-modelName=smalltalk.send(tokens,"_second",[]);
+tokens=smalltalk.send(smalltalk.send(smalltalk.send(tokens,"_second",[]),"_tokenize_",[" "]),"_select_",[(function(each){
+return smalltalk.send(each,"_notEmpty",[]);
+})]);
+tokens;
+modelName=smalltalk.send(tokens,"_first",[]);
 modelName;
-return smalltalk.send([modelName],"_trapDescend_",[(function(){
+path=smalltalk.send((smalltalk.Trapped || Trapped),"_parse_",[smalltalk.send(tokens,"_allButFirst",[])]);
+path;
+return smalltalk.send(smalltalk.send([modelName],"__comma",[path]),"_trapDescend_",[(function(){
 return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_at_",[viewName]),"_new",[]),"_appendToJQuery_",[jq]);
 })]);
 })]);
@@ -188,6 +195,34 @@ return self}
 smalltalk.Trapped);
 
 
+smalltalk.addMethod(
+"_parse_",
+smalltalk.method({
+selector: "parse:",
+fn: function (anArray){
+var self=this;
+var $2,$3,$1;
+$1=smalltalk.send(anArray,"_collect_",[(function(each){
+var asNum;
+asNum = parseInt(each);
+;
+$2=smalltalk.send(asNum,"__eq",[asNum]);
+if(smalltalk.assert($2)){
+return asNum;
+} else {
+$3=smalltalk.send(smalltalk.send(each,"_first",[]),"__eq",["#"]);
+if(smalltalk.assert($3)){
+return smalltalk.send(smalltalk.send(each,"_allButFirst",[]),"_asSymbol",[]);
+} else {
+return each;
+};
+};
+})]);
+return $1;
+}
+}),
+smalltalk.Trapped.klass);
+
 smalltalk.addMethod(
 "_path",
 smalltalk.method({
@@ -287,11 +322,14 @@ fn: function (path,aBlock){
 var self=this;
 smalltalk.send(path,"_trapDescend_",[(function(){
 var actual;
+var model;
 actual=smalltalk.send((smalltalk.Trapped || Trapped),"_path",[]);
 actual;
+model=smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_byName_",[smalltalk.send(actual,"_first",[])]);
+model;
 return smalltalk.send((function(){
-return smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_read_do_",[actual,(function(model){
-return smalltalk.send(aBlock,"_value_value_",[self,model]);
+return smalltalk.send(model,"_read_do_",[smalltalk.send(actual,"_allButFirst",[]),(function(data){
+return smalltalk.send(aBlock,"_value_value_",[self,data]);
 })]);
 }),"_fork",[]);
 })]);

+ 78 - 35
js/Trapped-Frontend.js

@@ -1,5 +1,5 @@
 smalltalk.addPackage('Trapped-Frontend', {});
-smalltalk.addClass('TrappedFly', smalltalk.Object, ['payload'], 'Trapped-Frontend');
+smalltalk.addClass('TrappedPlainModel', smalltalk.Object, ['payload'], 'Trapped-Frontend');
 smalltalk.addMethod(
 "_name",
 smalltalk.method({
@@ -16,7 +16,7 @@ source: "name\x0a\x09^ self class name",
 messageSends: ["name", "class"],
 referencedClasses: []
 }),
-smalltalk.TrappedFly);
+smalltalk.TrappedPlainModel);
 
 smalltalk.addMethod(
 "_payload",
@@ -32,7 +32,7 @@ source: "payload\x0a\x09^payload",
 messageSends: [],
 referencedClasses: []
 }),
-smalltalk.TrappedFly);
+smalltalk.TrappedPlainModel);
 
 smalltalk.addMethod(
 "_payload_",
@@ -48,7 +48,27 @@ source: "payload: anObject\x0a\x09payload := anObject",
 messageSends: [],
 referencedClasses: []
 }),
-smalltalk.TrappedFly);
+smalltalk.TrappedPlainModel);
+
+smalltalk.addMethod(
+"_read_do_",
+smalltalk.method({
+selector: "read:do:",
+category: 'action',
+fn: function (path,aBlock){
+var self=this;
+var data;
+data=smalltalk.send(path,"_inject_into_",[smalltalk.send(self,"_payload",[]),(function(soFar,segment){
+return smalltalk.send(soFar,"_at_",[segment]);
+})]);
+smalltalk.send(aBlock,"_value_",[data]);
+return self},
+args: ["path", "aBlock"],
+source: "read: path do: aBlock\x0a\x09| data |\x0a    data := path inject: self payload\x0a    \x09into: [ :soFar :segment | soFar at: segment ].\x0a\x09aBlock value: data.",
+messageSends: ["inject:into:", "payload", "at:", "value:"],
+referencedClasses: []
+}),
+smalltalk.TrappedPlainModel);
 
 smalltalk.addMethod(
 "_start",
@@ -64,7 +84,7 @@ source: "start\x0a\x09Trapped current register: self name: self name",
 messageSends: ["register:name:", "name", "current"],
 referencedClasses: ["Trapped"]
 }),
-smalltalk.TrappedFly);
+smalltalk.TrappedPlainModel);
 
 
 smalltalk.addMethod(
@@ -81,7 +101,7 @@ source: "start\x0a\x09self new start",
 messageSends: ["start", "new"],
 referencedClasses: []
 }),
-smalltalk.TrappedFly.klass);
+smalltalk.TrappedPlainModel.klass);
 
 
 smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
@@ -181,26 +201,6 @@ referencedClasses: []
 }),
 smalltalk.Trapped);
 
-smalltalk.addMethod(
-"_read_do_",
-smalltalk.method({
-selector: "read:do:",
-category: 'accessing',
-fn: function (path,aBlock){
-var self=this;
-var model;
-model=smalltalk.send(smalltalk.send(path,"_allButFirst",[]),"_inject_into_",[smalltalk.send(smalltalk.send(self,"_byName_",[smalltalk.send(path,"_first",[])]),"_payload",[]),(function(soFar,segment){
-return smalltalk.send(soFar,"_at_",[segment]);
-})]);
-smalltalk.send(aBlock,"_value_",[model]);
-return self},
-args: ["path", "aBlock"],
-source: "read: path do: aBlock\x0a\x09| model |\x0a    model := path allButFirst\x0a    \x09inject: (self byName: path first) payload\x0a        into: [ :soFar :segment | soFar at: segment ].\x0a\x09aBlock value: model.",
-messageSends: ["inject:into:", "payload", "byName:", "first", "at:", "allButFirst", "value:"],
-referencedClasses: []
-}),
-smalltalk.Trapped);
-
 smalltalk.addMethod(
 "_register_name_",
 smalltalk.method({
@@ -230,6 +230,7 @@ var jq;
 var viewName;
 var modelName;
 var tokens;
+var path;
 jq=smalltalk.send(elem,"_asJQuery",[]);
 jq;
 trap=smalltalk.send(jq,"_attr_",["data-trap"]);
@@ -238,21 +239,60 @@ tokens=smalltalk.send(trap,"_tokenize_",[":"]);
 tokens;
 viewName=smalltalk.send(tokens,"_first",[]);
 viewName;
-modelName=smalltalk.send(tokens,"_second",[]);
+tokens=smalltalk.send(smalltalk.send(smalltalk.send(tokens,"_second",[]),"_tokenize_",[" "]),"_select_",[(function(each){
+return smalltalk.send(each,"_notEmpty",[]);
+})]);
+tokens;
+modelName=smalltalk.send(tokens,"_first",[]);
 modelName;
-return smalltalk.send([modelName],"_trapDescend_",[(function(){
+path=smalltalk.send((smalltalk.Trapped || Trapped),"_parse_",[smalltalk.send(tokens,"_allButFirst",[])]);
+path;
+return smalltalk.send(smalltalk.send([modelName],"__comma",[path]),"_trapDescend_",[(function(){
 return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk),"_current",[]),"_at_",[viewName]),"_new",[]),"_appendToJQuery_",[jq]);
 })]);
 })]);
 return self},
 args: [],
-source: "start\x0a\x09'[data-trap]' asJQuery each: [ :index :elem |\x0a    \x09| trap jq viewName modelName tokens |\x0a        jq := elem asJQuery.\x0a        trap := jq attr: 'data-trap'.\x0a        tokens := trap tokenize: ':'.\x0a        viewName := tokens first.\x0a        modelName := tokens second.\x0a        { modelName } trapDescend: [(Smalltalk current at: viewName) new appendToJQuery: jq].\x0a    ]",
-messageSends: ["each:", "asJQuery", "attr:", "tokenize:", "first", "second", "trapDescend:", "appendToJQuery:", "new", "at:", "current"],
-referencedClasses: ["Smalltalk"]
+source: "start\x0a\x09'[data-trap]' asJQuery each: [ :index :elem |\x0a    \x09| trap jq viewName modelName tokens path |\x0a        jq := elem asJQuery.\x0a        trap := jq attr: 'data-trap'.\x0a        tokens := trap tokenize: ':'.\x0a        viewName := tokens first.\x0a        tokens := (tokens second tokenize: ' ') select: [ :each | each notEmpty ].\x0a        modelName := tokens first.\x0a        path := Trapped parse: tokens allButFirst.\x0a        { modelName }, path trapDescend: [(Smalltalk current at: viewName) new appendToJQuery: jq].\x0a    ]",
+messageSends: ["each:", "asJQuery", "attr:", "tokenize:", "first", "select:", "notEmpty", "second", "parse:", "allButFirst", "trapDescend:", "appendToJQuery:", "new", "at:", "current", ","],
+referencedClasses: ["Trapped", "Smalltalk"]
 }),
 smalltalk.Trapped);
 
 
+smalltalk.addMethod(
+"_parse_",
+smalltalk.method({
+selector: "parse:",
+category: 'accessing',
+fn: function (anArray){
+var self=this;
+var $2,$3,$1;
+$1=smalltalk.send(anArray,"_collect_",[(function(each){
+var asNum;
+asNum = parseInt(each);
+;
+$2=smalltalk.send(asNum,"__eq",[asNum]);
+if(smalltalk.assert($2)){
+return asNum;
+} else {
+$3=smalltalk.send(smalltalk.send(each,"_first",[]),"__eq",["#"]);
+if(smalltalk.assert($3)){
+return smalltalk.send(smalltalk.send(each,"_allButFirst",[]),"_asSymbol",[]);
+} else {
+return each;
+};
+};
+})]);
+return $1;
+},
+args: ["anArray"],
+source: "parse: anArray\x0a\x09^anArray collect: [ :each |\x0a    \x09| asNum |\x0a       \x09<asNum = parseInt(each)>.\x0a        asNum = asNum ifTrue: [ asNum ] ifFalse: [\x0a\x09\x09\x09each first = '#' ifTrue: [ each allButFirst asSymbol ] ifFalse: [ each ]]]",
+messageSends: ["collect:", "ifTrue:ifFalse:", "asSymbol", "allButFirst", "=", "first"],
+referencedClasses: []
+}),
+smalltalk.Trapped.klass);
+
 smalltalk.addMethod(
 "_path",
 smalltalk.method({
@@ -388,18 +428,21 @@ fn: function (path,aBlock){
 var self=this;
 smalltalk.send(path,"_trapDescend_",[(function(){
 var actual;
+var model;
 actual=smalltalk.send((smalltalk.Trapped || Trapped),"_path",[]);
 actual;
+model=smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_byName_",[smalltalk.send(actual,"_first",[])]);
+model;
 return smalltalk.send((function(){
-return smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_read_do_",[actual,(function(model){
-return smalltalk.send(aBlock,"_value_value_",[self,model]);
+return smalltalk.send(model,"_read_do_",[smalltalk.send(actual,"_allButFirst",[]),(function(data){
+return smalltalk.send(aBlock,"_value_value_",[self,data]);
 })]);
 }),"_fork",[]);
 })]);
 return self},
 args: ["path", "aBlock"],
-source: "trap: path read: aBlock\x0a\x09path trapDescend: [ | actual |\x0a    \x09actual := Trapped path.\x0a       \x09\x22TODO register for later\x22\x0a        [ Trapped current read: actual do: [ :model |\x0a        \x09aBlock value: self value: model\x0a    \x09]] fork\x0a    ]",
-messageSends: ["trapDescend:", "path", "fork", "read:do:", "value:value:", "current"],
+source: "trap: path read: aBlock\x0a\x09path trapDescend: [ | actual model |\x0a    \x09actual := Trapped path.\x0a        model := Trapped current byName: actual first.\x0a       \x09\x22TODO register for later\x22\x0a        [ model read: actual allButFirst do: [ :data |\x0a        \x09aBlock value: self value: data\x0a    \x09]] fork\x0a    ]",
+messageSends: ["trapDescend:", "path", "byName:", "first", "current", "fork", "read:do:", "allButFirst", "value:value:"],
 referencedClasses: ["Trapped"]
 }),
 smalltalk.TagBrush);

+ 4 - 13
st/Trapped-Demo.st

@@ -1,12 +1,13 @@
 Smalltalk current createPackage: 'Trapped-Demo' properties: #{}!
-TrappedFly subclass: #App
+TrappedPlainModel subclass: #App
 	instanceVariableNames: ''
 	package: 'Trapped-Demo'!
 
 !App methodsFor: 'initialization'!
 
 initialize
-	self payload: #{'items'->#('hello' 'world')}
+	super initialize.
+	self payload: #{'items'->#('hello' 'world'). 'title' -> 'To-Do List'}
 ! !
 
 Widget subclass: #AppView
@@ -16,20 +17,10 @@ Widget subclass: #AppView
 !AppView methodsFor: 'rendering'!
 
 renderOn: html
-	html h2: 'To-Do List'.
+	html h2 trapShow: #('title').
 	html p trapShow: #('items')
 ! !
 
-TrappedFly subclass: #Name
-	instanceVariableNames: ''
-	package: 'Trapped-Demo'!
-
-!Name methodsFor: 'initialization'!
-
-initialize
-	self payload: 'To-Do List'
-! !
-
 Widget subclass: #NameView
 	instanceVariableNames: ''
 	package: 'Trapped-Demo'!

+ 28 - 18
st/Trapped-Frontend.st

@@ -1,9 +1,9 @@
 Smalltalk current createPackage: 'Trapped-Frontend' properties: #{}!
-Object subclass: #TrappedFly
+Object subclass: #TrappedPlainModel
 	instanceVariableNames: 'payload'
 	package: 'Trapped-Frontend'!
 
-!TrappedFly methodsFor: 'accessing'!
+!TrappedPlainModel methodsFor: 'accessing'!
 
 payload
 	^payload
@@ -13,17 +13,24 @@ payload: anObject
 	payload := anObject
 ! !
 
-!TrappedFly methodsFor: 'action'!
+!TrappedPlainModel methodsFor: 'action'!
 
 name
 	^ self class name
 !
 
+read: path do: aBlock
+	| data |
+    data := path inject: self payload
+    	into: [ :soFar :segment | soFar at: segment ].
+	aBlock value: data.
+!
+
 start
 	Trapped current register: self name: self name
 ! !
 
-!TrappedFly class methodsFor: 'action'!
+!TrappedPlainModel class methodsFor: 'action'!
 
 start
 	self new start
@@ -63,14 +70,6 @@ byName: aString
 	^ registry at: aString
 !
 
-read: path do: aBlock
-	| model |
-    model := path allButFirst
-    	inject: (self byName: path first) payload
-        into: [ :soFar :segment | soFar at: segment ].
-	aBlock value: model.
-!
-
 register: aFly name: aString
 	registry at: aString put: aFly
 ! !
@@ -79,13 +78,15 @@ register: aFly name: aString
 
 start
 	'[data-trap]' asJQuery each: [ :index :elem |
-    	| trap jq viewName modelName tokens |
+    	| trap jq viewName modelName tokens path |
         jq := elem asJQuery.
         trap := jq attr: 'data-trap'.
         tokens := trap tokenize: ':'.
         viewName := tokens first.
-        modelName := tokens second.
-        { modelName } trapDescend: [(Smalltalk current at: viewName) new appendToJQuery: jq].
+        tokens := (tokens second tokenize: ' ') select: [ :each | each notEmpty ].
+        modelName := tokens first.
+        path := Trapped parse: tokens allButFirst.
+        { modelName }, path trapDescend: [(Smalltalk current at: viewName) new appendToJQuery: jq].
     ]
 ! !
 
@@ -98,6 +99,14 @@ initialize
 
 !Trapped class methodsFor: 'accessing'!
 
+parse: anArray
+	^anArray collect: [ :each |
+    	| asNum |
+       	<asNum = parseInt(each)>.
+        asNum = asNum ifTrue: [ asNum ] ifFalse: [
+			each first = '#' ifTrue: [ each allButFirst asSymbol ] ifFalse: [ each ]]]
+!
+
 path
 	^TrappedPathStack current elements
 ! !
@@ -146,11 +155,12 @@ trapDescend: aBlock
 !TagBrush methodsFor: '*Trapped-Frontend'!
 
 trap: path read: aBlock
-	path trapDescend: [ | actual |
+	path trapDescend: [ | actual model |
     	actual := Trapped path.
+        model := Trapped current byName: actual first.
        	"TODO register for later"
-        [ Trapped current read: actual do: [ :model |
-        	aBlock value: self value: model
+        [ model read: actual allButFirst do: [ :data |
+        	aBlock value: self value: data
     	]] fork
     ]
 !