class Octopress::Ink::Assets::Sass

Attributes

exists[RW]
render[RW]

Public Class Methods

new(plugin, base, file) click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 7
def initialize(plugin, base, file)
  @plugin = plugin
  @base = base
  @file = file
  @media = media || 'all'
  @root = plugin.assets_path
  @dir = File.join(plugin.slug, base)
  @exists = {}
  file_check
end

Public Instance Methods

add() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 18
def add
  unless File.basename(file).start_with?('_')
    Plugins.add_css_tag tag
    Plugins.static_files << StaticFileContent.new(content, destination)
  end
end
content() click to toggle source
Calls superclass method
# File lib/octopress-ink/assets/sass.rb, line 39
def content
  @render ||= begin
    contents = super
    if payload
      Liquid::Template.parse(contents).render!({ 'plugin' => @plugin.config }.merge(payload))
    else
      contents
    end
  end

  PluginAssetPipeline.compile_sass(self)
end
destination() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 52
def destination
  File.join(base, plugin.slug, output_file_name)
end
disabled?() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 35
def disabled?
  is_disabled('sass', filename) || is_disabled('stylesheets', filename)
end
ext() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 25
def ext
  File.extname(path)
end
load_paths() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 29
def load_paths
  lp = [theme_load_path]
  lp.unshift user_load_path if Dir.exists? user_load_path
  lp
end

Private Instance Methods

alt_syntax_file() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 75
def alt_syntax_file
  ext = File.extname(file)
  alt_ext = (ext == '.scss' ? '.sass' : '.scss')
  file.sub(ext, alt_ext)
end
output_file_name() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 81
def output_file_name
  File.basename(file.sub('@','-'), '.*') << '.css'
end
theme_load_path() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 62
def theme_load_path
  File.expand_path(File.join(root, base))
end
user_load_path() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 58
def user_load_path
  File.join(Plugins.custom_dir, dir, File.dirname(file)).sub /\/\.$/, ''
end
user_path() click to toggle source
# File lib/octopress-ink/assets/sass.rb, line 66
def user_path
  # Allow Sass overrides to use either syntax
  if file =~ /s[ac]ss$/
    [File.join(user_dir, file), File.join(user_dir, alt_syntax_file)]
  else
    File.join user_dir, file
  end
end