Browse files

Hello Sample with Includes

  • Loading branch information...
1 parent e4d22d1 commit 60cccca229d58327aeeae3e8d597fc80b2a81c58 @ajlopez committed May 26, 2012
View
3 samples/helloinclude/footer.tpl
@@ -0,0 +1,3 @@
+<p>SimpleMvc Sample</p>
+</body>
+</html>
View
6 samples/helloinclude/header.tpl
@@ -0,0 +1,6 @@
+<html>
+<head>
+<title>SimpleMvc Sample ${title}</title>
+</head>
+<body>
+<h1>${title}</h1>
View
8 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'); #>
View
29 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.