Getting images from submodules

I'm creating a submodule. I was thinking the code in the submodule would be able to access images locally like this:
{kind: "Image", src: "images/AImage1.png"}
But I find I need to define the path, assuming my project is in /source/lib/MyProj like this:
{kind: "Image", src: "lib/MyProj/images/AImage1.png"}
Is there a cleaner (more generic way) to to this? This path also assumes (maybe that's okay) that an installed submodule path will be the same for all projects?

Comments

  • For our libraries, we use paths based on "$lib/onyx" or similar. We automatically setup $enyo and $lib aliases for use in paths based on those two directories, so I'd suggest you just check out your submodule into $lib and use the $lib/MyProj path for images and the like.
  • Right, the $lib works from the main project, but I'm trying to get the image within the submodule where the submodule code and image both exist.
    This works form the main project:
    {kind: "Image", src: "$lib/MyProj/images/AImage1.png"}
    But it doesn't work within the submodule. Within the submodule I would expect to reference the local path "images/AImage1.png" but it can't find it. If I try to reference the variable, I get a 404 in the console
    http://localhost:8888/$lib/MyProj/images/AImage1.png 404 (Not Found) 
    So I have to use "lib" instead of "$lib", this just doesn't feel right.
  • Hmmm, I just was looking for usage like this in onyx, but only found it in one of the samples. I'm surprised it doesn't work though, as all enyo.Control-derived controls, including enyo.Image use the common srcChanged code that calls enyo.path.rewrite().
Sign In or Register to comment.