though that just does relative or absolute URI resolving (adding the web app context stuff too etc). It doesn't do anything magical with coffee script.
If you want to keep the generated JS file as a separate resource in your app you might want to do something like...
then either have a servlet for converting the coffee -> js or use the coffeescript/cake watcher thingy. We don't as I type have a default coffee -> js servlet filter in Scalate (though it'd be pretty trivial to hack one in to be honest). But if play has that already you could just reuse it I guess.
Though if you want to include the content of the coffee file inside a page you can use the include function - so something like...
h1 hello world :&coffeescript #{include("/public/javascripts/sample.coffee")}
Though the above isn't terribly DRY; it'd probably be better to create a function to include a chunk of coffee using the filter. e.g. something like
h1 hello world = includeCoffee("/public/javascripts/sample.coffee")
There's so many ways to slice and dice this stuff ;-). did you want the JS to be a separate browser request right? If so did you want the URI to include "sample.coffee" (but return JS) or did you want to use a URI with "sample.js" and so have the server side realise "sample.js" should be generated from "sample.coffee"?
> though that just does relative or absolute URI resolving (adding the web app
> context stuff too etc). It doesn't do anything magical with coffee script.
> If you want to keep the generated JS file as a separate resource in your app
> you might want to do something like...
> then either have a servlet for converting the coffee -> js or use the
> coffeescript/cake watcher thingy. We don't as I type have a default coffee
> -> js servlet filter in Scalate (though it'd be pretty trivial to hack one
> in to be honest). But if play has that already you could just reuse it I
> guess.
> Though if you want to include the content of the coffee file inside a page
> you can use the include function - so something like...
> h1 hello world
> :&coffeescript
> #{include("/public/javascripts/sample.coffee")}
> Though the above isn't terribly DRY; it'd probably be better to create a
> function to include a chunk of coffee using the filter. e.g. something like
> h1 hello world
> = includeCoffee("/public/javascripts/sample.coffee")
> There's so many ways to slice and dice this stuff ;-). did you want the JS
> to be a separate browser request right? If so did you want the URI to
> include "sample.coffee" (but return JS) or did you want to use a URI with
> "sample.js" and so have the server side realise "sample.js" should be
> generated from "sample.coffee"?
Yes, I want the JS to be a separate browser request. Or rather, I'd
like to see something like the Play CoffeeScript plugin in Scala -
where a link to a CoffeeScript file is compiled on-the-fly and
returned as CSS. This is done by using @asset like the following
example.
However, even if you add that, I'm not sure it'd give me what I want.
Because as soon as you give me this ability, then I'm going to want
the ability to concatenate and minimize my JS and CSS files. Now that
I think of it, it might be easiest if I figure out how to integrate
wro4j into Play, since it has a CoffeeScript compiler, supports LESS,
etc.
>> though that just does relative or absolute URI resolving (adding the web app >> context stuff too etc). It doesn't do anything magical with coffee script.
>> If you want to keep the generated JS file as a separate resource in your app >> you might want to do something like...
>> then either have a servlet for converting the coffee -> js or use the >> coffeescript/cake watcher thingy. We don't as I type have a default coffee >> -> js servlet filter in Scalate (though it'd be pretty trivial to hack one >> in to be honest). But if play has that already you could just reuse it I >> guess.
>> Though if you want to include the content of the coffee file inside a page >> you can use the include function - so something like...
>> h1 hello world >> :&coffeescript >> #{include("/public/javascripts/sample.coffee")}
>> Though the above isn't terribly DRY; it'd probably be better to create a >> function to include a chunk of coffee using the filter. e.g. something like
>> h1 hello world >> = includeCoffee("/public/javascripts/sample.coffee")
>> There's so many ways to slice and dice this stuff ;-). did you want the JS >> to be a separate browser request right? If so did you want the URI to >> include "sample.coffee" (but return JS) or did you want to use a URI with >> "sample.js" and so have the server side realise "sample.js" should be >> generated from "sample.coffee"?
> Yes, I want the JS to be a separate browser request. Or rather, I'd > like to see something like the Play CoffeeScript plugin in Scala - > where a link to a CoffeeScript file is compiled on-the-fly and > returned as CSS. This is done by using @asset like the following > example.
> However, even if you add that, I'm not sure it'd give me what I want. > Because as soon as you give me this ability, then I'm going to want > the ability to concatenate and minimize my JS and CSS files.
>>> though that just does relative or absolute URI resolving (adding the web app >>> context stuff too etc). It doesn't do anything magical with coffee script.
>>> If you want to keep the generated JS file as a separate resource in your app >>> you might want to do something like...
>>> then either have a servlet for converting the coffee -> js or use the >>> coffeescript/cake watcher thingy. We don't as I type have a default coffee >>> -> js servlet filter in Scalate (though it'd be pretty trivial to hack one >>> in to be honest). But if play has that already you could just reuse it I >>> guess.
>>> Though if you want to include the content of the coffee file inside a page >>> you can use the include function - so something like...
>>> h1 hello world >>> :&coffeescript >>> #{include("/public/javascripts/sample.coffee")}
>>> Though the above isn't terribly DRY; it'd probably be better to create a >>> function to include a chunk of coffee using the filter. e.g. something like
>>> h1 hello world >>> = includeCoffee("/public/javascripts/sample.coffee")
>>> There's so many ways to slice and dice this stuff ;-). did you want the JS >>> to be a separate browser request right? If so did you want the URI to >>> include "sample.coffee" (but return JS) or did you want to use a URI with >>> "sample.js" and so have the server side realise "sample.js" should be >>> generated from "sample.coffee"?
>> Yes, I want the JS to be a separate browser request. Or rather, I'd >> like to see something like the Play CoffeeScript plugin in Scala - >> where a link to a CoffeeScript file is compiled on-the-fly and >> returned as CSS. This is done by using @asset like the following >> example.
> >> So you can refer to templates/resources/files/images/css relative to your
> >> web applications context using the uri scala function. e.g. in jade
> >> though that just does relative or absolute URI resolving (adding the web app
> >> context stuff too etc). It doesn't do anything magical with coffee script.
> >> If you want to keep the generated JS file as a separate resource in your app
> >> you might want to do something like...
> >> then either have a servlet for converting the coffee -> js or use the
> >> coffeescript/cake watcher thingy. We don't as I type have a default coffee
> >> -> js servlet filter in Scalate (though it'd be pretty trivial to hack one
> >> in to be honest). But if play has that already you could just reuse it I
> >> guess.
> >> Though if you want to include the content of the coffee file inside a page
> >> you can use the include function - so something like...
> >> Though the above isn't terribly DRY; it'd probably be better to create a
> >> function to include a chunk of coffee using the filter. e.g. something like
> >> h1 hello world
> >> = includeCoffee("/public/javascripts/sample.coffee")
> >> There's so many ways to slice and dice this stuff ;-). did you want the JS
> >> to be a separate browser request right? If so did you want the URI to
> >> include "sample.coffee" (but return JS) or did you want to use a URI with
> >> "sample.js" and so have the server side realise "sample.js" should be
> >> generated from "sample.coffee"?
> > Yes, I want the JS to be a separate browser request. Or rather, I'd
> > like to see something like the Play CoffeeScript plugin in Scala -
> > where a link to a CoffeeScript file is compiled on-the-fly and
> > returned as CSS. This is done by using @asset like the following
> > example.
> > >> So you can refer to templates/resources/files/images/css relative to your
> > >> web applications context using the uri scala function. e.g. in jade
> > >> though that just does relative or absolute URI resolving (adding the web app
> > >> context stuff too etc). It doesn't do anything magical with coffee script.
> > >> If you want to keep the generated JS file as a separate resource in your app
> > >> you might want to do something like...
> > >> then either have a servlet for converting the coffee -> js or use the
> > >> coffeescript/cake watcher thingy. We don't as I type have a default coffee
> > >> -> js servlet filter in Scalate (though it'd be pretty trivial to hack one
> > >> in to be honest). But if play has that already you could just reuse it I
> > >> guess.
> > >> Though if you want to include the content of the coffee file inside a page
> > >> you can use the include function - so something like...
> > >> Though the above isn't terribly DRY; it'd probably be better to create a
> > >> function to include a chunk of coffee using the filter. e.g. something like
> > >> There's so many ways to slice and dice this stuff ;-). did you want the JS
> > >> to be a separate browser request right? If so did you want the URI to
> > >> include "sample.coffee" (but return JS) or did you want to use a URI with
> > >> "sample.js" and so have the server side realise "sample.js" should be
> > >> generated from "sample.coffee"?
> > > Yes, I want the JS to be a separate browser request. Or rather, I'd
> > > like to see something like the Play CoffeeScript plugin in Scala -
> > > where a link to a CoffeeScript file is compiled on-the-fly and
> > > returned as CSS. This is done by using @asset like the following
> > > example.
> I'm guessing this is because of Scala 2.9 vs. 2.8. Is this enhancement
> available on the 2.8 branch?
I tried downloading the latest scala-2.8.x branch snapshot, building
and using those JARs in my application. Play doesn't like it because
it doesn't know how to process the .js and .css files. Here's the
error I get when using the external.jade and foo.coffee/mysass.scss
files in my application:
08:20:21,122 ERROR ~
@67o8fflce
Application.foo.js action not found
Action not found
Action Application.foo.js could not be found. Error raised is
Controller controllers.Application.foo not found
play.exceptions.ActionNotFoundException: Action Application.foo.js not
found
at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java:
588)
at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.Exception: Controller controllers.Application.foo
not found
... 3 more
08:20:21,133 ERROR ~
@67o8fflcf
Application.mysass.css action not found
Action not found
Action Application.mysass.css could not be found. Error raised is
Controller controllers.Application.mysass not found
play.exceptions.ActionNotFoundException: Action Application.mysass.css
not found
at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java:
588)
at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.Exception: Controller
controllers.Application.mysass not found
... 3 more
I'm guessing I need to figure out some sort of way to map .js and .css
requests to Scalate?
> > >> So you can refer to templates/resources/files/images/css relative to your > > >> web applications context using the uri scala function. e.g. in jade
> > >> though that just does relative or absolute URI resolving (adding the web app > > >> context stuff too etc). It doesn't do anything magical with coffee script.
> > >> If you want to keep the generated JS file as a separate resource in your app > > >> you might want to do something like...
> > >> then either have a servlet for converting the coffee -> js or use the > > >> coffeescript/cake watcher thingy. We don't as I type have a default coffee > > >> -> js servlet filter in Scalate (though it'd be pretty trivial to hack one > > >> in to be honest). But if play has that already you could just reuse it I > > >> guess.
> > >> Though if you want to include the content of the coffee file inside a page > > >> you can use the include function - so something like...
> > >> Though the above isn't terribly DRY; it'd probably be better to create a > > >> function to include a chunk of coffee using the filter. e.g. something like
> > >> There's so many ways to slice and dice this stuff ;-). did you want the JS > > >> to be a separate browser request right? If so did you want the URI to > > >> include "sample.coffee" (but return JS) or did you want to use a URI with > > >> "sample.js" and so have the server side realise "sample.js" should be > > >> generated from "sample.coffee"?
> > > Yes, I want the JS to be a separate browser request. Or rather, I'd > > > like to see something like the Play CoffeeScript plugin in Scala - > > > where a link to a CoffeeScript file is compiled on-the-fly and > > > returned as CSS. This is done by using @asset like the following > > > example.
> I'm guessing this is because of Scala 2.9 vs. 2.8. Is this enhancement > available on the 2.8 branch?
I tried downloading the latest scala-2.8.x branch snapshot, building and using those JARs in my application. Play doesn't like it because it doesn't know how to process the .js and .css files. Here's the error I get when using the external.jade and foo.coffee/mysass.scss files in my application:
08:20:21,122 ERROR ~
@67o8fflce Application.foo.js action not found
Action not found Action Application.foo.js could not be found. Error raised is Controller controllers.Application.foo not found
play.exceptions.ActionNotFoundException: Action Application.foo.js not found at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java: 588) at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85) at Invocation.HTTP Request(Play!) Caused by: java.lang.Exception: Controller controllers.Application.foo not found ... 3 more 08:20:21,133 ERROR ~
@67o8fflcf Application.mysass.css action not found
Action not found Action Application.mysass.css could not be found. Error raised is Controller controllers.Application.mysass not found
play.exceptions.ActionNotFoundException: Action Application.mysass.css not found at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java: 588) at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85) at Invocation.HTTP Request(Play!) Caused by: java.lang.Exception: Controller controllers.Application.mysass not found ... 3 more
I'm guessing I need to figure out some sort of way to map .js and .css requests to Scalate?
> I tried downloading the latest scala-2.8.x branch snapshot, building > and using those JARs in my application. Play doesn't like it because > it doesn't know how to process the .js and .css files. Here's the > error I get when using the external.jade and foo.coffee/mysass.scss > files in my application:
> 08:20:21,122 ERROR ~
> @67o8fflce > Application.foo.js action not found
> Action not found > Action Application.foo.js could not be found. Error raised is > Controller controllers.Application.foo not found
> play.exceptions.ActionNotFoundException: Action Application.foo.js not > found > at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java: > 588) > at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85) > at Invocation.HTTP Request(Play!) > Caused by: java.lang.Exception: Controller controllers.Application.foo > not found > ... 3 more > 08:20:21,133 ERROR ~
> @67o8fflcf > Application.mysass.css action not found
> Action not found > Action Application.mysass.css could not be found. Error raised is > Controller controllers.Application.mysass not found
> play.exceptions.ActionNotFoundException: Action Application.mysass.css > not found > at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java: > 588) > at play.mvc.ActionInvoker.resolve(ActionInvoker.java:85) > at Invocation.HTTP Request(Play!) > Caused by: java.lang.Exception: Controller > controllers.Application.mysass not found > ... 3 more
> I'm guessing I need to figure out some sort of way to map .js and .css > requests to Scalate?
I was able to work something out. I changed external.jade to have:
> TemplateException occured : Not a template file extension (md | markdown | ssp | scaml | mustache | jade), you requested: coffee
Quick update. I was able to get past this because I discovered the Play CoffeeScript module[1] handles external CoffeeScript files. For example, in a Jade template: