I’m using static_url
to refer to static files that are located in the resources directory. This works fine when for literal URL strings but it doesn’t work for composite URLs that were constructed using variables:
static_url(foo + '/' + bar)
This is just ignored by SproutCore’s pre-processor.
So is there some way to refer to a static file with a composite URL? Or, since I’m working with a finite set of URLs, do I have to introduce each composite URL before I can refer to it?
This answers assumes that you are using SC1.
I believe that
static_url()
is processed by the build tools (sc-build and sc-server) at compile time and not the framework at runtime.The code for the build tools can be found at https://github.com/sproutcore/abbot. I believe
base.rb replace_static_url()
is where the work gets done.So the following code:
gets compiled into the following before being delivered to the browser:
To create composite URL at runtime, try using bindings.
Also, if you have a finite set of resources, you may want to give this a go:
You can change the image at runtime by setting
isFoo
to true or false.Hope this helps.