MCPcopy Index your code
hub / github.com/totaljs/framework / viewengine_read

Function viewengine_read

internal.js:3005–3056  ·  view source on GitHub ↗

* Read file * @param {String} path * @return {Object}

(path, controller)

Source from the content-addressed store, hash-verified

3003 * @return {Object}
3004 */
3005function viewengine_read(path, controller) {
3006 var config = CONF;
3007 var out = path[0] === '.';
3008 var filename = out ? path.substring(1) : F.path.views(path);
3009 var key;
3010
3011 if (RELEASE) {
3012 key = '404/' + path;
3013 var is = F.temporary.other[key];
3014 if (is !== undefined)
3015 return null;
3016 }
3017
3018 if (existsSync(filename))
3019 return view_parse(view_parse_localization(modificators(Fs.readFileSync(filename).toString('utf8'), filename, 'view', controller), controller.language), config.allow_compile_html, filename, controller);
3020
3021 var index;
3022
3023 if (out) {
3024
3025 if (controller.themeName) {
3026 index = filename.lastIndexOf('/');
3027 if (index !== -1) {
3028 filename = filename.substring(0, filename.lastIndexOf('/', index - 1)) + filename.substring(index);
3029 if (existsSync(filename))
3030 return view_parse(view_parse_localization(modificators(Fs.readFileSync(filename).toString('utf8'), filename, 'view', controller), controller.language), config.allow_compile_html, filename, controller);
3031 }
3032 }
3033
3034 if (RELEASE)
3035 F.temporary.other[key] = null;
3036
3037 return null;
3038 }
3039
3040 index = path.lastIndexOf('/');
3041 if (index === -1) {
3042 if (RELEASE)
3043 F.temporary.other[key] = null;
3044 return null;
3045 }
3046
3047 filename = F.path.views(path.substring(index + 1));
3048
3049 if (existsSync(filename))
3050 return view_parse(view_parse_localization(modificators(Fs.readFileSync(filename).toString('utf8'), filename, 'view', controller), controller.language), config.allow_compile_html, filename, controller);
3051
3052 if (RELEASE)
3053 F.temporary.other[key] = null;
3054
3055 return null;
3056}
3057
3058function modificators(value, filename, type, controller) {
3059

Callers 1

viewengine_loadFunction · 0.85

Calls 4

view_parseFunction · 0.85
view_parse_localizationFunction · 0.85
modificatorsFunction · 0.85
existsSyncFunction · 0.70

Tested by

no test coverage detected