mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-12 20:24:43 +08:00
15 lines
375 B
Ruby
15 lines
375 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class LabelTemplate < ApplicationRecord
|
||
|
enum language_type: { zpl: 0 }
|
||
|
validates :name, presence: true
|
||
|
validates :size, presence: true
|
||
|
validates :content, presence: true
|
||
|
|
||
|
def render(locals)
|
||
|
locals.reduce(content.dup) do |rendered_content, (key, value)|
|
||
|
rendered_content.gsub!(/\{\{#{key}\}\}/, value.to_s)
|
||
|
end
|
||
|
end
|
||
|
end
|