Skip to content

Instantly share code, notes, and snippets.

@tkfm-yamaguchi
Last active December 15, 2015 17:39
Show Gist options
  • Save tkfm-yamaguchi/5297952 to your computer and use it in GitHub Desktop.
Save tkfm-yamaguchi/5297952 to your computer and use it in GitHub Desktop.
# coding: utf-8
=begin
## Haml
http://haml.info/docs/yardoc/frames.html#!http%3A//haml.info/docs/yardoc/
http://haml.info/docs/yardoc/file.REFERENCE.html#options
=end
require 'haml'
require 'haml/template/options'
require 'date'
# set options
Haml::Template.options[:format] = :xhtml
Haml::Template.options[:autoclose] = [/.*/]
template = File.read('test.xml.haml')
haml_engine = Haml::Engine.new(template, Haml::Template.options)
output = haml_engine.render
puts output
<?xml version='1.0' encoding='utf-8' ?>
<charactors>
<created_at>2013-04-03</created_at>
<charactor>
<name>博麗霊夢</name>
<ability>空を飛ぶ程度の能力</ability>
</charactor>
<charactor>
<name />
<nickname>大妖精</nickname>
<ability />
</charactor>
</charactors>
!!! XML
%charactors
%created_at= Date.today
%charactor
%name 博麗霊夢
%ability 空を飛ぶ程度の能力
%charactor
%name
%nickname 大妖精
%ability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment