summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk>2015-01-21 17:47:21 +0000
committerNathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk>2015-01-21 17:47:21 +0000
commit2d392e7b167fdf0a6c76e287a0f78c7ff4f88d94 (patch)
treeeb4b862b19ca3a98c0173f7885fd1ae4709df7bb /lib
Initial commit
Diffstat (limited to 'lib')
-rw-r--r--lib/tag.rb27
-rw-r--r--lib/utils.rb11
-rw-r--r--lib/virgil.rb2
3 files changed, 40 insertions, 0 deletions
diff --git a/lib/tag.rb b/lib/tag.rb
new file mode 100644
index 0000000..bad0d01
--- /dev/null
+++ b/lib/tag.rb
@@ -0,0 +1,27 @@
+module Virgil
+ class Tag
+ class << self
+ def doctype
+ "<!DOCTYPE " + yield + ">"
+ end
+ def common(attrs = {})
+ "<#{__callee__}" + Utils.unfold(attrs) + ">" +
+ yield +
+ "</#{__callee__}>"
+ end
+ def common_single(attrs = {})
+ "<#{__callee__}" + Utils.unfold(attrs) + " />"
+ end
+
+ alias :html :common
+ alias :head :common
+ alias :title :common
+ alias :body :common
+ alias :h1 :common
+ alias :p :common
+ alias :img :common_single
+ alias :a :common
+
+ end
+ end
+end
diff --git a/lib/utils.rb b/lib/utils.rb
new file mode 100644
index 0000000..e3b96a9
--- /dev/null
+++ b/lib/utils.rb
@@ -0,0 +1,11 @@
+module Virgil
+ class Utils
+ def self.unfold(attrs)
+ ret = ""
+ attrs.each do |key, value|
+ ret += " #{key.to_s}=\"#{value}\""
+ end
+ ret
+ end
+ end
+end
diff --git a/lib/virgil.rb b/lib/virgil.rb
new file mode 100644
index 0000000..ef1c9fc
--- /dev/null
+++ b/lib/virgil.rb
@@ -0,0 +1,2 @@
+require './lib/utils'
+require './lib/tag'