Skip to content

Commit

Permalink
Hello Sample with Includes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlopez committed May 26, 2012
1 parent e4d22d1 commit 60cccca
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions samples/helloinclude/footer.tpl
@@ -0,0 +1,3 @@
<p>SimpleMvc Sample</p>
</body>
</html>
6 changes: 6 additions & 0 deletions samples/helloinclude/header.tpl
@@ -0,0 +1,6 @@
<html>
<head>
<title>SimpleMvc Sample ${title}</title>
</head>
<body>
<h1>${title}</h1>
8 changes: 8 additions & 0 deletions samples/helloinclude/hello.tpl
@@ -0,0 +1,8 @@

<# include('header', { title: 'Hello, world' }); #>

<h3>I'm a template, using includes</h3>

<h3>Current time ${new Date()}</h3>

<# include('footer'); #>
29 changes: 29 additions & 0 deletions samples/helloinclude/server.js
@@ -0,0 +1,29 @@
var express = require('express'),
fs = require('fs'),
path = require('path'),
simplemvc = require('../../');

// Create MVC application object

var mvc = simplemvc.createApplication();

// Register action with file view name, no process

mvc.get('/', 'hello');

// Register view as file template

mvc.view('hello', path.join(__dirname, 'hello.tpl'));
mvc.view('header', path.join(__dirname, 'header.tpl'));
mvc.view('footer', path.join(__dirname, 'footer.tpl'));

// Create the server, register actions and launch it

express.createServer()
.use(express.favicon())
.use(express.logger())
.use(express.router(function(app){
mvc.registerActions(app);
})).listen(8000);

console.log('listening to http://localhost:8000');

0 comments on commit 60cccca

Please sign in to comment.