Skip to content

Commit

Permalink
feat(app generator,view subgenerator): normalize template expansion
Browse files Browse the repository at this point in the history
Make template part a view class property.
Add renderData method.
  • Loading branch information
cueedee committed Apr 13, 2015
1 parent 6aa0d3c commit bc32f20
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 11 deletions.
31 changes: 30 additions & 1 deletion generators/app/templates/demo/views/buildscript.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@
className: 'buildscript-view'


###*
# The compiled handlebars template expander function.
#
# @property template
#
# @type Function
# @protected
# @static
# @final
###

template: template


###*
# @method render
#
Expand All @@ -72,10 +86,25 @@

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )
@$el.html( @template( @renderData() ) )

## This method is chainable.
##
return @


###*
# Collect and return all data needed to expand the handlebars `@template` with
#
# @method renderData
# @protected
#
# @return {Object}
#
###

renderData: () ->

return {}

)
31 changes: 30 additions & 1 deletion generators/app/templates/demo/views/documentation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@
className: 'documentation-view'


###*
# The compiled handlebars template expander function.
#
# @property template
#
# @type Function
# @protected
# @static
# @final
###

template: template


###*
# @method render
#
Expand All @@ -70,10 +84,25 @@

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )
@$el.html( @template( @renderData() ) )

## This method is chainable.
##
return @


###*
# Collect and return all data needed to expand the handlebars `@template` with
#
# @method renderData
# @protected
#
# @return {Object}
#
###

renderData: () ->

return {}

)
37 changes: 32 additions & 5 deletions generators/app/templates/demo/views/i18n.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@
className: 'i18n-view'


###*
# The compiled handlebars template expander function.
#
# @property template
#
# @type Function
# @protected
# @static
# @final
###

template: template


###*
# Setup UI event handler definitions.
#
Expand All @@ -90,11 +104,7 @@

## Expand the handlebars template into this view's container element.
##
@$el.html( template(
date: new Date()
money: 100000
number: 1090870987
))
@$el.html( @template( @renderData() ) )

## Set the current locale as selected option.
##
Expand All @@ -105,6 +115,23 @@
return @


###*
# Collect and return all data needed to expand the handlebars `@template` with
#
# @method renderData
# @protected
#
# @return {Object}
#
###

renderData: () ->

date: new Date()
money: 100000
number: 1090870987


###*
# Handles changes to the selected language.
#
Expand Down
31 changes: 30 additions & 1 deletion generators/app/templates/demo/views/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@
className: 'index-view'


###*
# The compiled handlebars template expander function.
#
# @property template
#
# @type Function
# @protected
# @static
# @final
###

template: template


###*
# @method render
#
Expand All @@ -72,10 +86,25 @@

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )
@$el.html( @template( @renderData() ) )

## This method is chainable.
##
return @


###*
# Collect and return all data needed to expand the handlebars `@template` with
#
# @method renderData
# @protected
#
# @return {Object}
#
###

renderData: () ->

return {}

)
30 changes: 29 additions & 1 deletion generators/app/templates/demo/views/navigation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@
className: 'navigation-view'


###*
# The compiled handlebars template expander function.
#
# @property template
#
# @type Function
# @protected
# @static
# @final
###

template: template


###*
# @method render
#
Expand All @@ -58,7 +72,7 @@

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )
@$el.html( @template( @renderData() ) )

# Set reference to the navbar
#
Expand All @@ -69,6 +83,20 @@
return @


###*
# Collect and return all data needed to expand the handlebars `@template` with
#
# @method renderData
# @protected
#
# @return {Object}
#
###

renderData: () ->

return {}

###*
# Set the activeMenuItem based on the url passed.
#
Expand Down
31 changes: 30 additions & 1 deletion generators/app/templates/src/views/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@
className: 'index-view'


###*
# The compiled handlebars template expander function.
#
# @property template
#
# @type Function
# @protected
# @static
# @final
###

template: template


###*
# @method initialize
# @protected
Expand Down Expand Up @@ -95,10 +109,25 @@

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )
@$el.html( @template( @renderData() ) )

## This method is chainable.
##
return @


###*
# Collect and return all data needed to expand the handlebars `@template` with
#
# @method renderData
# @protected
#
# @return {Object}
#
###

renderData: () ->

return {}

)
31 changes: 30 additions & 1 deletion generators/view/templates/view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@
className: '<%= fileName %>-view'


###*
# The compiled handlebars template expander function.
#
# @property template
#
# @type Function
# @protected
# @static
# @final
###

template: template


###*
# @method initialize
# @protected
Expand Down Expand Up @@ -95,10 +109,25 @@

## Expand the handlebars template into this view's container element.
##
@$el.html( template() )
@$el.html( @template( @renderData() ) )

## This method is chainable.
##
return @


###*
# Collect and return all data needed to expand the handlebars `@template` with
#
# @method renderData
# @protected
#
# @return {Object}
#
###

renderData: () ->

return {}

)

0 comments on commit bc32f20

Please sign in to comment.