-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started refactoring to simplify context handling.
- Loading branch information
renato
committed
Mar 3, 2019
1 parent
e558e06
commit 4981222
Showing
6 changed files
with
85 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package mg | ||
|
||
type MapContext struct { | ||
Map map[string]interface{} | ||
} | ||
|
||
var _ Context = (*MapContext)(nil) | ||
|
||
func (m *MapContext) Get(name string) (interface{}, bool) { | ||
v, ok := m.Map[name] | ||
return v, ok | ||
} | ||
|
||
func (m *MapContext) Set(name string, value interface{}) { | ||
m.Map[name] = value | ||
} | ||
|
||
func (m *MapContext) IsEmpty() bool { | ||
return len(m.Map) == 0 | ||
} | ||
|
||
func (m *MapContext) mixInto(other Context) { | ||
for k, v := range m.Map { | ||
other.Set(k, v) | ||
} | ||
} |
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,22 @@ | ||
package mg | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
) | ||
|
||
type StringContent struct { | ||
Text string | ||
} | ||
|
||
func (c *StringContent) Write(writer io.Writer, files WebFilesMap, inclusionChain []InclusionChainItem) error { | ||
_, err := writer.Write([]byte(c.Text)) | ||
if err != nil { | ||
return &MagnanimousError{Code: IOError, message: err.Error()} | ||
} | ||
return nil | ||
} | ||
|
||
func (c *StringContent) String() string { | ||
return fmt.Sprintf("StringContent{%s}", c.Text) | ||
} |
Oops, something went wrong.