Sha256: 49d328c0375304a7f7242fccaf47e066a690b9edaa65a683a081c66dc056721e

Contents?: true

Size: 915 Bytes

Versions: 4

Compression:

Stored size: 915 Bytes

Contents

describe "Conditional block components" do
  include CompilationSupport

  example "with neither identifier nor attributes" do
    define_presenter do
      def high?
        true
      end

      def low?
        false
      end
    end

    render("{{#high?}}yup{{/high?}}").should == "yup"
    render("{{#low?}}nah{{/low?}}").should == ""
  end

  example "with an identifier" do
    define_presenter do
      def even?(number)
        number.to_i % 2 == 0
      end
    end

    render("{{#even.42?}}even{{/even.42?}}").should == "even"
    render("{{#even.13?}}even{{/even.13?}}").should == ""
  end

  example "with attributes" do
    define_presenter do
      def square?(width:, height:)
        width.to_i == height.to_i
      end
    end

    render("{{#square? width=2 height=2}}square{{/square?}}").should == "square"
    render("{{#square? width=3 height=2}}square{{/square?}}").should == ""
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
curly-templates-2.5.0 spec/conditional_blocks_spec.rb
curly-templates-2.4.1 spec/conditional_blocks_spec.rb
curly-templates-2.4.0 spec/conditional_blocks_spec.rb
curly-templates-2.3.2 spec/conditional_blocks_spec.rb