 NgOnRailsApp.directive "render", ->
   restrict: "AE",
   transclude: true,
+  link: set_data
   template: (el,attrs)->
     format = attrs.format || "html"
     url_parts = attrs.url.split("/")

    path = url_parts.join("/")
    '<div ng_include="\'/angular_app/'+path+'.'+format+'\'"></div>'


#
# NgOnRails: View Helper Directives
#

# NgOnRails: Render Directives
#

set_data = (scope,el,attrs)->
  if !!attrs['data']
    data_array = attrs['data'].split(";")
    for data in data_array
      key_val_arr = data.split("=")
      scope[key_val_arr[0].trim()] = scope.$eval(key_val_arr[1].trim())

NgOnRailsApp.directive "renderView", ->
  restrict: "AE",
  transclude: true,
  link: set_data
  template: (el,attrs)->
    format = attrs.format || "html"
    '<div ng_include="\'/angular_app/'+attrs.url+'.'+format+'\'"></div>'
