= Data Pages The Data Pages extension allows you to pull in external JSON-formatted files and bind them to a template. Templates can be conditionally formatted based on the absence or presence of some data. The json gem is required (not ruby-json). gem install json No other installation necessary. == Page Types * DataPage: Base class that adds external data tags. * VirtualDataPage: A data page that can pull any one of several external data depending on its slug. == Tags * : Outermost tag; has the source url to pull from. * : Debugging statement that prints the current data context (only if the page is Draft). * : Sets the current data context. Prints if it's single, expands if it's double. * : Expands itself over all of the members of the current data context (assuming it's an Array). * and : Conditional expansions based on the current data context. * , , : Formats the current data context and outputs it. == Gotchas Make sure you're not hosting the JSON resources in the same server process as Radiant. Since Rails is not threadsafe, this will cause deadlock (the template page will be waiting for the JSON resource, which will not be retrieved since Radiant is blocking...). == Examples === Simple example localhost/some_data.js { "name": "Andrew", "favorite_color": "red... no -- blue!", "monkeys": [ "rhesus", "howler" ] } localhost:3000/template (body part)

My name is

My favorite color is

Output

My name is Andrew

My favorite color is red... no -- blue!

  • rhesus
  • howler
== Credits Andrew O'Brien Jan 8, 2008