Let's say I have a piece of jQuery javascript that binds to a div on load and dynamically defines an img in that div. Something like this:
$(document).ready(function() {
$("#container").html("<img href='/images/myimage.jpg/>');
});
If I were to use this inlined in a Laravel view, I'd be able to use HTML::image() and Blade templates to specify the location of image. Something like this:
$(document).ready(function() {
$("#container").html("{{ HTML::image('images/myimage.jpg', 'My image') }}");
});
If I were then to take that piece of javascript, and, instead of inlining it in the view, place it inside a separate .js file, say, public/js/image.js, I could have Laravel load it as an asset;
Asset::add('image.js', 'js/image.js');
However, since it's now treated only as an asset, neither the Laravel PHP nor the Blade templating code is processed, so we literally get the string {{ HTML::image('images/myimage.jpg', 'My image') }} in the resulting html, instead of the templated-in values.
Is there a good approach for something like this?