-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provides a document level `.header` method passing its block a header object having essentially the same functionality as a table cell but rendering as a document header. It writes content to a document level header_content object rendered separately as `word/header.xml`. This means you can write ``` docx.header do |header| header.p 'hello there' end ``` or ``` docx.header do |header| header.table [[one cell]] end ```
- Loading branch information
Ben Ketron
committed
Jan 9, 2020
1 parent
cd015cc
commit 5895814
Showing
16 changed files
with
283 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'caracal/core/models/header_model' | ||
require 'caracal/errors' | ||
|
||
|
||
module Caracal | ||
module Core | ||
|
||
# This module encapsulates all the functionality related to adding a header | ||
# to every page of the document. | ||
# | ||
module Header | ||
def self.included(base) | ||
base.class_eval do | ||
|
||
#------------------------------------------------------------- | ||
# Public Methods | ||
#------------------------------------------------------------- | ||
|
||
def header(*args, &block) | ||
options = Caracal::Utilities.extract_options!(args) | ||
|
||
model = Caracal::Core::Models::HeaderModel.new(options, &block) | ||
|
||
@header_content = model | ||
|
||
model | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'caracal/core/models/base_model' | ||
require 'caracal/core/models/margin_model' | ||
require 'caracal/core/models/paragraph_model' | ||
|
||
|
||
module Caracal | ||
module Core | ||
module Models | ||
|
||
# This class handles block options passed to tables via their data | ||
# collections. | ||
# | ||
class HeaderModel < BaseModel | ||
|
||
#------------------------------------------------------------- | ||
# Configuration | ||
#------------------------------------------------------------- | ||
|
||
# initialization | ||
def initialize(options={}, &block) | ||
super options, &block | ||
end | ||
|
||
#------------------------------------------------------------- | ||
# Public Methods | ||
#------------------------------------------------------------- | ||
|
||
#=============== DATA ACCESSORS ======================= | ||
|
||
def contents | ||
@contents ||= [] | ||
end | ||
|
||
#=============== VALIDATION =========================== | ||
|
||
def valid? | ||
contents.size > 0 | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.