Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[ @ ] Partials and Bugfixes

  • Loading branch information...
commit 2d8bb535afdc206060af546f94169993b26f4e1e 1 parent f51f9a2
@pnegri authored
Showing with 26 additions and 5 deletions.
  1. +25 −4 lib/arcabouco.coffee
  2. +1 −1  package.json
View
29 lib/arcabouco.coffee
@@ -39,6 +39,7 @@ Template =
unless @loadedTemplates[ templateFile ]
return false
@loadedTemplates[ templateFile ]
+
loadTemplate: ( templateFile, asTemplateName="" ) ->
unless templateFile
return false
@@ -50,19 +51,34 @@ Template =
template = Common.Fs.readFileSync templateFile, 'utf-8'
compiledTemplate = Haml.compile template
optimizedTemplate = Haml.optimize compiledTemplate
- @loadedTemplates[ baseTemplateFile ] = optimizedTemplate
+ @loadedTemplates[ baseTemplateFile ] =
+ type: 'haml'
+ data: optimizedTemplate
+
+ loadTemplateString: ( templateString, templateName ) ->
+ @loadedTemplates[ templateName ] =
+ type: 'plain'
+ data: templateString
doRender: ( templateFile, context = this, params = {}, layout = 'layout.haml' ) ->
template = @getTemplate templateFile
unless template
- return false
- content = Haml.execute template, context, params
+ return 'Template Missing: ' + templateFile
+
+ if template.type == 'haml'
+ content = Haml.execute template.data, context, params
+ else
+ content = template.data
+
if layout
compiled_layout = @getTemplate layout
params.content = content
return Haml.execute layout, context, params
return content
+ doRenderPartial: ( templateFile, context = this, params = {}) ->
+ @doRender templateFile, context, params, false
+
## Register Modules???
class Arcabouco
@@ -158,11 +174,16 @@ class Arcabouco
if controllerFilename.indexOf('.') == 0
controllerFilename = @config.baseDirectory + controllerFilename.substring(1)
- ControllerObject = require controllerFilename
+ ControllerObject = new (require controllerFilename)()
ControllerObject.bootstrap( this ) if ControllerObject.bootstrap
@parseControllerRoutes @controllerInstances.push(ControllerObject)-1
work: ( ControllerObject ) ->
+
+ instanceClass = new ControllerObject()
+ if instanceClass.bootstrap or instanceClass.getRoutes
+ ControllerObject = instanceClass
+
ControllerObject.bootstrap( this ) if ControllerObject.bootstrap
@parseControllerRoutes @controllerInstances.push(ControllerObject)-1
View
2  package.json
@@ -1,7 +1,7 @@
{
"name" : "arcabouco-js",
"description" : "scalable microframework in node.js",
- "version" : "0.6.0",
+ "version" : "0.6.1",
"author" : "Patrick Negri <patrick@iugu.com.br>",
"homepage": "http://github.com/pnegri/arcabouco-js",
"contributors" : [],
Please sign in to comment.
Something went wrong with that request. Please try again.