4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/nexmo_markdown_renderer/filters/partial_filter.rb', line 4
def call(input)
input.gsub(/```partial(.+?)```/m) do |_s|
config = YAML.safe_load($1)
file_path = if config['source'].start_with? 'app/views'
"#{Rails.root}/#{config['source']}"
else
"#{Nexmo::Markdown::Config.docs_base_path}/#{config['source']}"
end
content = File.read(file_path)
active = options[:code_language] ? options[:code_language].key == config['platform'] : false
if config['platform']
" <div class=\"js-platform\" data-platform=\"\#{config['platform']}\" data-active=\"\#{active}\">\n \#{content.render_markdown}\n </div>\n HEREDOC\n else\n content\n end\n end\nend\n"
|