Sha256: 6333f184223df7ae0b45441bbc62412ab41bd5a82f076ea5668b99aff4e51f7f

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

= Formats

We have created a set of sample documents in the samples directory.
We will take each format in turn.

  formats = %w{erb liquid}

Included with the format samples are files containing the expected results
of each rendering.

  expected_output = {}

  formats.each do |format|
    expected_output[format] = File.read("qed/samples/output-#{format}.txt")
  end

The data to inject into the formats that interpolate, is also stored in the
samples folder.

  data = YAML.load(File.new('qed/samples/data.yml'))

Now we can render each of thes formats, and verify we get the expected result.

  formats.each do |format|
    output = Malt.render(:file=>"qed/samples/sample.#{format}", :format=>format, :data=>data)
    output.assert == expected_output[format]
  end

Notice that formats the do not use interpolation data simply ignore it even
if it is given.

We can also handle the files in a more object-oriented manner.

  formats.each do |format|
    object = Malt.file("qed/samples/sample.#{format}", :format=>format)
    output = object.render(data)
    output.assert == expected_output[format]
  end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
malt-0.3.0 qed/02_formats.rdoc
malt-0.2.0 qed/02_formats.rdoc
malt-0.1.1 qed/02_formats.rdoc