I'm trying to dynamically update a table of values using SocketStream. I have a Jade template defining the table:
app.jade:
table
thead
tr
th key
th value
tbody
- var jadeItems = [{key:'Test',value:'3.1415'}, {key:'Test2',value:'2.1878'}]
- each item in jadeItems
tr
td= item.key
td= item.value
This works for the static data, and now I need to make it dynamic. I have client-side CoffeeScript that receives a SocketStream message containing the new values for the table in JSON format:
app.coffee:
SS.events.on('message', (message) ->
jadeItems = JSON.parse(message)
)
I am trying to figure out how to replace the JSON value of items in Jade with with the content of the message, but the 'jadeItems' variable is out of scope in the client-side CoffeeScript.
I am able to stuff the new JSON into a Jade element, but then I'm unsure how to get the values for the element in the 'jadeItems' variable within Jade.
Does anyone know the Jade syntax for getting the value of a Jade element? Or is there a way to assign to the items variable defined in Jade from within the client-side CoffeeScript? Are there any solid references for Jade syntax?