From fc08e0399aeb854f22805afa02d45c765c3ffa01 Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Mon, 12 Aug 2024 13:30:54 +0100 Subject: [PATCH] Add dynamic tag method --- lib/phlex/sgml.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/phlex/sgml.rb b/lib/phlex/sgml.rb index fe627e14..9ee40f88 100644 --- a/lib/phlex/sgml.rb +++ b/lib/phlex/sgml.rb @@ -206,6 +206,38 @@ def capture(*args, &block) end end + def tag(name, ...) + name = case name + when Symbol then name.name.downcase + when String then name.downcase + else raise ArgumentError.new("Expected the tag namea as a Symbol or String.") + end + + if name == "script" + raise ArgumentError.new("You can’t use the `