[eluser]MaartenDeGroote[/eluser]
Hi all,
I am currently playing around with Sammy.js and CouchDB in CodeIgniter.
All is going well and I followed the snippet found in on the Sammy homepage
Code:
// initialize the application
var app = Sammy('#main', function() {
// include a plugin
this.use('Mustache');
// define a 'route'
this.get('#/', function() {
// load some data
this.load('posts.json')
// render a template
.renderEach('post.mustache')
// swap the DOM with the new content
.swap();
});
});
// start the application
app.run('#/');
Note that the extensions .json and .mustache are arbitrary to get the example to work.
I created a controller called "app", which, until now, contains two methods: "get", and "view". The "get"-method contacts the CouchDb via cURL and then simply returns a JSON object.
The "view"-method loads a template view that contains html and mustache pseudo-variables to be interpolated.
The following code DOES NOT work
Code:
// initialize the application
var app = Sammy('#main', function() {
// include a plugin
this.use('Mustache');
// define a 'route'
this.get('#/', function() {
// load some data
this.load('/app/get')
// render a template
.renderEach('/app/view')
// swap the DOM with the new content
.swap();
});
});
// start the application
app.run('#/');
However, the following code DOES work
Code:
// initialize the application
var app = Sammy('#main', function() {
// include a plugin
this.use('Mustache');
// define a 'route'
this.get('#/', function() {
// load some data
this.load('/app/get/.json')
// render a template
.renderEach('/app/view/.mustache')
// swap the DOM with the new content
.swap();
});
});
// start the application
app.run('#/');
Obviously, I am very glad it does! But I want to know how CodeIgniter interprets the .json and .mustache extensions in the controllers. Is it seen as an argument or just ignored (because I don't get an error) ?
Thanx in advance!
Maarten