Sha256: 0f123c1f13052926a5443eec35b7007a485835c1bd6347603e4ffc04f0e2943f

Contents?: true

Size: 605 Bytes

Versions: 1

Compression:

Stored size: 605 Bytes

Contents

class Lalala::Markdown::Handlers::LazyAsset < Lalala::Markdown::Handlers::Base

  def initialize(options={})
    @options = options
  end

  def image(url, alt=nil, title=nil)
    unless %r|^asset[:]//(.+)$| === url
      return ""
    end

    id_with_version = $1.split("/")
    id = id_with_version[0]
    version = id_with_version[1] || "original"

    # build url
    url = "//" + File.join(
      "c." + Haraway.configuration.endpoint,
      id,
      version.to_s)

    # build img element
    <<-EOS
      <img class="js-lazy" data-src="#{url}" alt="#{alt}" title="#{title}" />
    EOS
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lalala-4.1.0.dev.358 lib/lalala/markdown/handlers/lazy_asset.rb