Skip to content

Commit 87374f9

Browse files
committed
Changes to revel to support a template engine architecture
1 parent fa40869 commit 87374f9

File tree

5 files changed

+572
-273
lines changed

5 files changed

+572
-273
lines changed

results.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (r *RenderTemplateResult) render(req *Request, resp *Response, wr io.Writer
231231
}
232232

233233
var templateContent []string
234-
templateName, line, description := parseTemplateError(err)
234+
templateName, line, description := ParseTemplateError(err)
235235
if templateName == "" {
236236
templateName = r.Template.Name()
237237
templateContent = r.Template.Content()

revel.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ const (
2222
// RevelImportPath Revel framework import path
2323
RevelImportPath = "github.com/revel/revel"
2424
)
25+
const (
26+
// Called when templates are going to be refreshed (receivers are registered template engines added to the template.engine conf option)
27+
TEMPLATE_REFRESH = iota
28+
// Called when templates are refreshed (receivers are registered template engines added to the template.engine conf option)
29+
TEMPLATE_REFRESH_COMPLETE
2530

31+
)
2632
type revelLogs struct {
2733
c gocolorize.Colorize
2834
w io.Writer
2935
}
3036

37+
type EventHandler func(typeOf int, value interface{}) (responseOf int)
38+
3139
func (r *revelLogs) Write(p []byte) (n int, err error) {
3240
return r.w.Write([]byte(r.c.Paint(string(p))))
3341
}
@@ -111,6 +119,7 @@ var (
111119
// Private
112120
secretKey []byte // Key used to sign cookies. An empty key disables signing.
113121
packaged bool // If true, this is running from a pre-built package.
122+
initEventList = []EventHandler{} // Event handler list for receiving events
114123
)
115124

116125
// Init initializes Revel -- it provides paths for getting around the app.
@@ -230,6 +239,25 @@ func Init(mode, importPath, srcPath string) {
230239
INFO.Printf("Initialized Revel v%s (%s) for %s", Version, BuildDate, MinimumGoVersion)
231240
}
232241

242+
// Fires system events from revel
243+
func fireEvent(key int, value interface{}) (response int) {
244+
for _, handler := range initEventList {
245+
response |= handler(key, value)
246+
}
247+
return
248+
}
249+
250+
// Add event handler to listen for all system events
251+
func AddInitEventHandler(handler EventHandler) {
252+
initEventList = append(initEventList, handler)
253+
return
254+
}
255+
256+
func SetSecretKey(newKey []byte) error {
257+
secretKey = newKey
258+
return nil
259+
}
260+
233261
// Create a logger using log.* directives in app.conf plus the current settings
234262
// on the default logger.
235263
func getLogger(name string) *log.Logger {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy