Class: Optimacms::TemplateTranslation

Inherits:
ApplicationRecord show all
Defined in:
app/models/optimacms/template_translation.rb

Instance Method Summary collapse

Instance Method Details

#contentObject

content


11
12
13
14
15
16
# File 'app/models/optimacms/template_translation.rb', line 11

def content
  filename =  fullpath
  return nil if filename.nil?
  return '' if !File.exists? filename
  File.read(filename)
end

#content=(v) ⇒ Object


18
19
20
21
22
# File 'app/models/optimacms/template_translation.rb', line 18

def content=(v)
  File.open(self.fullpath, "w+") do |f|
    f.write(v)
  end
end

#filename_baseObject

base filename depending on type for page = name for partial = _name


30
31
32
33
# File 'app/models/optimacms/template_translation.rb', line 30

def filename_base
  return '_'+basename if is_type_partial?
  basename
end

#fullpathObject


41
42
43
44
45
# File 'app/models/optimacms/template_translation.rb', line 41

def fullpath
  f = path
  return nil if f.nil?
  Template.base_dir + f
end

#pathObject


36
37
38
39
# File 'app/models/optimacms/template_translation.rb', line 36

def path
  return nil if basename.nil?
  basedirpath + filename_base + Template.filename_lang_postfix(lang) + Template.filename_ext_with_dot(self.tpl_format)
end