MCPcopy Create free account
hub / github.com/kataras/iris / Load

Method Load

view/django.go:224–259  ·  view source on GitHub ↗

Load parses the templates to the engine. It is responsible to add the necessary global functions. Returns an error if something bad happens, user is responsible to catch it.

()

Source from the content-addressed store, hash-verified

222//
223// Returns an error if something bad happens, user is responsible to catch it.
224func (s *DjangoEngine) Load() error {
225 // If only custom templates should be loaded.
226 if (s.fs == nil || context.IsNoOpFS(s.fs)) && len(s.templateCache) > 0 {
227 return nil
228 }
229
230 rootDirName := getRootDirName(s.fs)
231
232 return walk(s.fs, "", func(path string, info os.FileInfo, err error) error {
233 if err != nil {
234 return err
235 }
236
237 if info == nil || info.IsDir() {
238 return nil
239 }
240
241 if s.extension != "" {
242 if !strings.HasSuffix(path, s.extension) {
243 return nil
244 }
245 }
246
247 if s.rootDir == rootDirName {
248 path = strings.TrimPrefix(path, rootDirName)
249 path = strings.TrimPrefix(path, "/")
250 }
251
252 contents, err := asset(s.fs, path)
253 if err != nil {
254 return err
255 }
256
257 return s.ParseTemplate(path, contents)
258 })
259}
260
261// ParseTemplate adds a custom template from text.
262// This parser does not support funcs per template. Use the `AddFunc` instead.

Callers 1

ExecuteWriterMethod · 0.95

Calls 6

ParseTemplateMethod · 0.95
IsNoOpFSFunction · 0.92
getRootDirNameFunction · 0.85
walkFunction · 0.85
assetFunction · 0.70
IsDirMethod · 0.45

Tested by

no test coverage detected