1

In Jekyll/Octopress, how can I place the output of a tag inside another tag?
This is what I want to do (using Octopress's img tag):

{% img {% PluginThatOutputsAURL %} %}

If I do that I get this error:

Error processing input, expected syntax: {% img [class name(s)] [http[s]:/]/path/to/image [width [height]] [title text | “title text” [“alt text”]] %} %}

Is it possible to do this? What would be the right syntax to do so?

Rafael
  • 7,002
  • 5
  • 43
  • 52
Eric
  • 16,003
  • 15
  • 87
  • 139

1 Answers1

0

Jekyll/Octopress uses Liquid Templates to parse these things.

As far as I know, you can't call two functions within a tag like that. You can however specify variable names in tags:

using Liquid variables inside of a liquid tag call

I tried Googling a bit and didn't see anything pop up for calling two functions within one tag.

IMO, I'd recommend creating a custom tag to do exactly what you want. I have created several custom plugins to Octopress because I needed such customization. The plugins, which is just Ruby. is pretty straight forward.

So, copy the existing img_tag.rb and call it, mycustom_img_tag.rb or whatever, and perform your magic within the render() method.

For example, here's my HTML5 audio player tag I wrote where I needed to know what extension the audio file was (specified in the url) in order to specify the content type:

https://github.com/eduncan911/eduncan911.github.io/blob/b89f47cd86c37f2cfb5c3093612fe0a049808325/plugins/audio_tag.rb

^- NOTE: It is incomplete and all the options doesn't work as I specified. You can see what works in the render() section, where I just parse the data-* attributes manually (I ran outta time and just made it work).

I basically used two other plugins as a template and created this one.

You have access to the entire Octopress methods and variables in your plugin - there are no restrictions to the entire code base.

Community
  • 1
  • 1
eduncan911
  • 17,165
  • 13
  • 68
  • 104