Class: Wpgen::Generator
- Inherits:
-
Object
- Object
- Wpgen::Generator
- Defined in:
- lib/wpgen/generator.rb
Constant Summary collapse
- @@templates_dir =
File.("../../templates", File.dirname(__FILE__))
Class Method Summary collapse
- .custom_post_type(type) ⇒ Object
- .dynamic_sidebar(sidebar_name) ⇒ Object
- .page_template(template_name) ⇒ Object
Class Method Details
.custom_post_type(type) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/wpgen/generator.rb', line 6 def self.custom_post_type type File.open("#{@@templates_dir}/post-type.php", "r") do |f| php_code = f.read php_code.gsub!(/WPGEN_Token/, type.capitalize) php_code.gsub!(/WPGEN_token/, type.downcase) end end |
.dynamic_sidebar(sidebar_name) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/wpgen/generator.rb', line 21 def self. File.open("#{@@templates_dir}/register-sidebar.php") do |f| php_code = f.read php_code.gsub!(/WPGEN_Token/, .capitalize) php_code.gsub!(/wpgen-token/, .downcase.gsub(/\s/, "-")) end end |
.page_template(template_name) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/wpgen/generator.rb', line 14 def self.page_template template_name File.open("#{@@templates_dir}/page-template.php", "r") do |f| php_code = f.read php_code.gsub!(/WPGEN_Token/, template_name.capitalize) end end |