Sha256: 46a47f743c7a433a287a38c43ae7c996ce8bcc1fe779e675c3e38417f63d995d

Contents?: true

Size: 600 Bytes

Versions: 29

Compression:

Stored size: 600 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]

    # build url
    url = "//" + [
      "c." + Haraway.configuration.endpoint,
      id,
      version
    ].compact.join("/")

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

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
lalala-4.1.0.dev.387 lib/lalala/markdown/handlers/lazy_asset.rb
lalala-4.1.0.dev.386 lib/lalala/markdown/handlers/lazy_asset.rb
lalala-4.1.0.dev.384 lib/lalala/markdown/handlers/lazy_asset.rb
lalala-4.1.0.dev.381 lib/lalala/markdown/handlers/lazy_asset.rb
lalala-4.1.0.dev.376 lib/lalala/markdown/handlers/lazy_asset.rb
lalala-4.1.0.dev.375 lib/lalala/markdown/handlers/lazy_asset.rb
lalala-4.1.0.dev.367 lib/lalala/markdown/handlers/lazy_asset.rb
lalala-4.1.0.dev.360 lib/lalala/markdown/handlers/lazy_asset.rb
lalala-4.1.0.dev.359 lib/lalala/markdown/handlers/lazy_asset.rb