rabl icon indicating copy to clipboard operation
rabl copied to clipboard

Mandatory object in partial

Open denisovlev opened this issue 9 years ago • 1 comments

If I want to render a partial that does not require an object, like:

# some_template.json.rabl
node(:common) do
  # I cannot do like this
  # partial('common/duration_units')
  # and like this
  # partial('common/duration_units', object: {})
  # I have to do:
  partial('common/duration_units', object: {a: 123})
end

# common/duration_units.json.rabl
node(:available_duration_units) do
  DURATION_UNITS.map do |unit|
    {
        name: unit.name,
        multiplier: unit.multiplier
    }
  end
end

From my point of view it is not the best solution and there should be a way to render a partial without an object. Another way is to use extends but I completely fail to understand how to use it whatsoever

denisovlev avatar Jun 18 '15 10:06 denisovlev

extends should work exactly the same way as partial in you situation?

extends('common/duration_units') doesn't work?

You'll have to rename your file to common/_duration_units.rabl (note the underscore)

ethicalhack3r avatar Sep 02 '15 15:09 ethicalhack3r