Module: DirectInject::PublicApi

Includes:
InternalHelpers
Included in:
DirectInject
Defined in:
lib/direct_inject/public_api.rb

Constant Summary

Constants included from InternalHelpers

InternalHelpers::ASSET_EXTENSIONS

Instance Method Summary collapse

Instance Method Details

#render_image(*sources) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/direct_inject/public_api.rb', line 9

def render_image( *sources )
  render *sources do | asset , options |
    options.set \
      'data',
      'direct_inject_type',
      'image'

    encoded = data_uri_for asset

    Templates::Image.render \
      encoded,
      options
  end
end

#render_javascript(*sources) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/direct_inject/public_api.rb', line 24

def render_javascript( *sources )
  options = Map.opts! sources

  options.set \
    'type',
    :javascript

  sources.push options

  render *sources do | asset , options |
    options.set \
      'data',
      'direct_inject_type',
      'javascript'

    options.set \
      'type',
      'text/javascript'

    Templates::Javascript.render \
      asset.to_s,
      options
  end
end

#render_stylesheet(*sources) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/direct_inject/public_api.rb', line 49

def render_stylesheet( *sources )
  options = Map.opts! sources

  options.set \
    'type',
    :stylesheet

  sources.push options

  render *sources do | asset , options |
    options.set \
      'data',
      'direct_inject_type',
      'stylesheet'

    options.set \
      'type',
      'text/css'

    Templates::Stylesheet.render \
      asset.to_s,
      options
  end
end