Uploaded image for project: 'Forge: Scalate'
  1. Forge: Scalate
  2. SCALATE-28

support the mapping of an XML element to a function

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Someday
    • Component/s: scalate-core
    • Labels:
      None

      Description

      It might be nice to support custom tags using XML markup notation as well.

      This came up on this thread...
      http://old.nabble.com/Re%3A-JSP-taglibs-in-Scala-p27514294.html

      <html xmlns:foo="scala:org.acme.MyTags"> 
       ... 
       <foo:cheese blah="123"> 
         ... 
         ${something} 
         ... 
       </foo:cheese> 
      </html> 

      which would translate to the equivalent of this...

      <html>
      <% import org.acme.MyTags._ %> 
       ... 
       <%= cheese(blah="123")  { %> 
         ... 
         ${something} 
         ... 
       <% } %>
      </html> 

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            villane Erkki Lindpere added a comment -

            Would this work with singletons only? It would be nice if it also worked with default constructors of classes, then I could trigger dependency injection manually in the constructor (I think at least Guice allows that, but I haven't tried).

            Or maybe the uri scheme could be pluggable, for example "guice:org.acme.MyTags" and I could extend Scalate with a Guice provider. Or Spring etc.

            Show
            villane Erkki Lindpere added a comment - Would this work with singletons only? It would be nice if it also worked with default constructors of classes, then I could trigger dependency injection manually in the constructor (I think at least Guice allows that, but I haven't tried). Or maybe the uri scheme could be pluggable, for example "guice:org.acme.MyTags" and I could extend Scalate with a Guice provider. Or Spring etc.
            Hide
            jastrachan James Strachan added a comment -

            interesting idea! Using JAXRS controllers with things like Jersey works like this. It makes total sense to support IoC in the same way too.

            Initially I was thinking the namespace would basically just map to an import; so the "org.acme.MyTags" just basically does...

            import org.acme.MyTags._

            but maybe we need to support instantiation of a tag library as a variable; then instantiate that. So something like this...

            val myTagLib = injector.createInstance(classOf[org.acme.MyTags])
            import myTagLib._

            Maybe we need a slight different namespace URI to differentiate against the IoC created instance versus the straight import.

            maybe something like this...

            <html xmlns:foo="import:org.acme.MyTags._"> ...

            where the import is basically in the namespace URI so that you could exclude some imports or rename methods etc.

            Then we have explicit injection of a type...

            <html xmlns:foo="inject:com.acme.Foo"> ...

            Show
            jastrachan James Strachan added a comment - interesting idea! Using JAXRS controllers with things like Jersey works like this. It makes total sense to support IoC in the same way too. Initially I was thinking the namespace would basically just map to an import; so the "org.acme.MyTags" just basically does... import org.acme.MyTags._ but maybe we need to support instantiation of a tag library as a variable; then instantiate that. So something like this... val myTagLib = injector.createInstance(classOf[org.acme.MyTags]) import myTagLib._ Maybe we need a slight different namespace URI to differentiate against the IoC created instance versus the straight import. maybe something like this... <html xmlns:foo="import:org.acme.MyTags._"> ... where the import is basically in the namespace URI so that you could exclude some imports or rename methods etc. Then we have explicit injection of a type... <html xmlns:foo="inject:com.acme.Foo"> ...

              People

              • Assignee:
                Unassigned
                Reporter:
                jastrachan James Strachan
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Development