Method: Sass::Script::Functions#content_exists

Defined in:
lib/sass/script/functions.rb

#content_existsSass::Script::Value::Bool

Check whether a mixin was passed a content block.

Unless content-exists() is called directly from a mixin, an error will be raised.

Examples:

@mixin needs-content {
  @if not content-exists() {
    @error "You must pass a content block!"
  }
  @content;
}

Returns:



2568
2569
2570
2571
2572
2573
2574
2575
2576
# File 'lib/sass/script/functions.rb', line 2568

def content_exists
  # frames.last is the stack frame for this function,
  # so we use frames[-2] to get the frame before that.
  mixin_frame = environment.stack.frames[-2]
  unless mixin_frame && mixin_frame.type == :mixin
    raise Sass::SyntaxError.new("Cannot call content-exists() except within a mixin.")
  end
  bool(!environment.caller.content.nil?)
end