Repurpose mixin.rb as utils.rb
This commit is contained in:
parent
7530169fa3
commit
3f910de546
6 changed files with 17 additions and 13 deletions
2
Rules
2
Rules
|
@ -12,7 +12,7 @@ require "nanoc-tidy"
|
|||
|
||||
##
|
||||
# Extensions
|
||||
[Nanoc::RuleDSL::CompilationRuleContext, Nanoc::RuleDSL::CompilerDSL].each { _1.prepend(Mixin) }
|
||||
[Nanoc::RuleDSL::CompilationRuleContext, Nanoc::RuleDSL::CompilerDSL].each { _1.prepend(Utils) }
|
||||
Nanoc::RuleDSL::CompilationRuleContext.prepend(Nanoc::Extension::AnonymousFilter)
|
||||
Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::Extension::RequireRules)
|
||||
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Mixin
|
||||
##
|
||||
# The {Utils Utils} module provides methods that are
|
||||
# available at build time. Both ERB templates and the
|
||||
# Rules file have access to the methods of this module.
|
||||
module Utils
|
||||
require "test-cmd"
|
||||
require_relative "mixin/t"
|
||||
require_relative "mixin/inline"
|
||||
require_relative "mixin/erb"
|
||||
require_relative "mixin/opengraph"
|
||||
require_relative "utils/t"
|
||||
require_relative "utils/inline"
|
||||
require_relative "utils/erb"
|
||||
require_relative "utils/opengraph"
|
||||
|
||||
##
|
||||
# @return [Ryo::Object]
|
||||
|
@ -74,4 +78,4 @@ module Mixin
|
|||
include ERB
|
||||
include OpenGraph
|
||||
end
|
||||
use_helper Mixin
|
||||
use_helper Utils
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
##
|
||||
# The {Mixin::ERB Mixin::ERB} module provides a method
|
||||
# The {Utils::ERB Utils::ERB} module provides a method
|
||||
# that can render an ERB template
|
||||
module Mixin::ERB
|
||||
module Utils::ERB
|
||||
##
|
||||
# @param [String] file
|
||||
# The path to an ERB template
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Mixin::Inline
|
||||
module Utils::Inline
|
||||
def inline_json(path, class_name: File.basename(path, File.extname(path)))
|
||||
%|<script class="json #{class_name}" type="application/json">| \
|
||||
"#{items[path].compiled_content}" \
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Mixin::OpenGraph
|
||||
module Utils::OpenGraph
|
||||
def opengraph(context)
|
||||
erb "_opengraph.html.erb", local_assigns(context)
|
||||
end
|
|
@ -1,10 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
##
|
||||
# The {Mixin::T Mixin::T} module provides a method that
|
||||
# The {Utils::T Utils::T} module provides a method that
|
||||
# can render user-facing text strings in different
|
||||
# locales / languages
|
||||
module Mixin::T
|
||||
module Utils::T
|
||||
##
|
||||
# @param [String] locale
|
||||
# Locale (eg "en")
|
Loading…
Reference in a new issue