Skip to content

Commit

Permalink
Complete the Directive interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovic Claude committed Mar 25, 2015
1 parent 5d2c956 commit 0174679
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
21 changes: 11 additions & 10 deletions src/main/scala/biz/enef/angulate/Directive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,41 @@ import scala.scalajs.js
* Interface to be implemented by classes that represent an AngularJS directive.
*/
trait Directive {
// def name: String = ???
def name: String = ???
def restrict: String = ??? // subset of EACM
// def multiElement: Boolean = ???
// def replace: Boolean = ??? - deprecated
// def terminal: Boolean = ???
// def require: js.Any = ??? -string or array of strings
def multiElement: Boolean = ???
@Deprecated
def replace: Boolean = ???
def terminal: Boolean = ???
def require: js.Any = ??? // string or array of strings

def transclude: Boolean = ???

def priority: Int = ???

def controller(ctrl: ControllerType, scope: ScopeType, elem: JQLite, attrs: Attributes) : Unit = ???

//def controller(scope: js.Dynamic, elem: JQLite, attrs: Attributes) : Unit = ???

type ControllerType <: js.Any
type ScopeType <: js.Any

def controllerAs: String = ???
//def bindToController: Boolean = ???

def template: String = ???
def template(element: JQLite, attrs: Attributes) : String = ???

def templateUrl: String = ???
def templateUrl(element: JQLite, attrs: Attributes) : String = ???
// def templateNamespace: String = ???
def templateNamespace: String = ???

def scope: Boolean = ???
def isolateScope: js.Dictionary[String] = ???
// def bindToController: Boolean = ???
def bindToController: Boolean = ???

def postLink(scope: ScopeType, element: JQLite, attrs: Attributes) : Unit = ???
def postLink(scope: ScopeType, element: JQLite, attrs: Attributes, controller: ControllerType) : Unit = ???
//def preLink(scope: Scope, element: JQLite, attrs: Attributes, controller: js.Dynamic) : Unit = ???
def preLink(scope: ScopeType, element: JQLite, attrs: Attributes) : Unit = ???
def preLink(scope: ScopeType, element: JQLite, attrs: Attributes, controller: ControllerType) : Unit = ???

def compile(tElement: js.Dynamic, tAttrs: Attributes) : js.Any = ???
}
5 changes: 3 additions & 2 deletions src/main/scala/biz/enef/angulate/impl/DirectiveMacros.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ protected[angulate] class DirectiveMacros(val c: blackbox.Context) extends Macro
val module = Select(c.prefix.tree, TermName("self"))

// assemble all defined directive attributes (ie 'template', 'restrict', ...)
val atts = (getDirectiveAttributes(ct).map( a => (a.name.toString,a)) map {
val atts = getDirectiveAttributes(ct).map( a => (a.name.toString,a)) map {
case ("isolateScope",_) => q"scope = dimpl.isolateScope"
case ("preLink",_) => q"link = dimpl.preLink _"
case ("postLink",_) => q"link = dimpl.postLink _"
case ("controller",_) => q"""controller = js.Array("$$scope","$$element","$$attrs",(dimpl.controller _):js.ThisFunction)"""
case (_,a) if a.isGetter => q"${a.name} = dimpl.${a.name}"
case (_,a) => q"${a.name} = (dimpl.${a.name} _):js.Function"
})
}

// create directive definition object
val ddo = q"""literal( ..$atts )"""
Expand Down

0 comments on commit 0174679

Please sign in to comment.