Update reference docs with most recent version of brodocs (#4600)
* Update 1.7 apidocs with new brodocs * Update 1.7 resource reference docs with new brodocs * Update 1.7 kubectl reference docs with new brodocs
This commit is contained in:
committed by
Andrew Chen
parent
4b004cf717
commit
217c86642f
+71
-46
@@ -121,16 +121,36 @@ exports.resolveInclude = function(name, filename, isDir) {
|
||||
* @param {Options} options compilation options
|
||||
* @return {String}
|
||||
*/
|
||||
function getIncludePath(path, options){
|
||||
function getIncludePath(path, options) {
|
||||
var includePath;
|
||||
var filePath;
|
||||
var views = options.views;
|
||||
|
||||
// Abs path
|
||||
if (path.charAt(0) == '/') {
|
||||
includePath = exports.resolveInclude(path.replace(/^\/*/,''), options.root || '/', true);
|
||||
}
|
||||
// Relative paths
|
||||
else {
|
||||
if (!options.filename) {
|
||||
throw new Error('`include` use relative path requires the \'filename\' option.');
|
||||
// Look relative to a passed filename first
|
||||
if (options.filename) {
|
||||
filePath = exports.resolveInclude(path, options.filename);
|
||||
if (fs.existsSync(filePath)) {
|
||||
includePath = filePath;
|
||||
}
|
||||
}
|
||||
// Then look in any views directories
|
||||
if (!includePath) {
|
||||
if (Array.isArray(views) && views.some(function (v) {
|
||||
filePath = exports.resolveInclude(path, v, true);
|
||||
return fs.existsSync(filePath);
|
||||
})) {
|
||||
includePath = filePath;
|
||||
}
|
||||
}
|
||||
if (!includePath) {
|
||||
throw new Error('Could not find include include file.');
|
||||
}
|
||||
includePath = exports.resolveInclude(path, options.filename);
|
||||
}
|
||||
return includePath;
|
||||
}
|
||||
@@ -390,8 +410,13 @@ exports.renderFile = function () {
|
||||
// in the data, copy them to options
|
||||
if (arguments.length === 3) {
|
||||
// Express 4
|
||||
if (data.settings && data.settings['view options']) {
|
||||
utils.shallowCopyFromList(opts, data.settings['view options'], _OPTS_EXPRESS);
|
||||
if (data.settings) {
|
||||
if (data.settings['view options']) {
|
||||
utils.shallowCopyFromList(opts, data.settings['view options'], _OPTS_EXPRESS);
|
||||
}
|
||||
if (data.settings.views) {
|
||||
opts.views = data.settings.views;
|
||||
}
|
||||
}
|
||||
// Express 3 and lower
|
||||
else {
|
||||
@@ -442,6 +467,7 @@ function Template(text, opts) {
|
||||
options.rmWhitespace = opts.rmWhitespace;
|
||||
options.root = opts.root;
|
||||
options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
|
||||
options.views = opts.views;
|
||||
|
||||
if (options.strict) {
|
||||
options._with = false;
|
||||
@@ -505,10 +531,6 @@ Template.prototype = {
|
||||
src = this.source;
|
||||
}
|
||||
|
||||
if (opts.debug) {
|
||||
console.log(src);
|
||||
}
|
||||
|
||||
if (opts.client) {
|
||||
src = 'escapeFn = escapeFn || ' + escapeFn.toString() + ';' + '\n' + src;
|
||||
if (opts.compileDebug) {
|
||||
@@ -519,6 +541,9 @@ Template.prototype = {
|
||||
if (opts.strict) {
|
||||
src = '"use strict";\n' + src;
|
||||
}
|
||||
if (opts.debug) {
|
||||
console.log(src);
|
||||
}
|
||||
|
||||
try {
|
||||
fn = new Function(opts.localsName + ', escapeFn, include, rethrow', src);
|
||||
@@ -611,7 +636,7 @@ Template.prototype = {
|
||||
+ ' try {' + '\n'
|
||||
+ includeObj.source
|
||||
+ ' } catch (e) {' + '\n'
|
||||
+ ' rethrow(e, __lines, __filename, __line);' + '\n'
|
||||
+ ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
|
||||
+ ' }' + '\n'
|
||||
+ ' ; }).call(this)' + '\n';
|
||||
}else{
|
||||
@@ -657,43 +682,43 @@ Template.prototype = {
|
||||
return arr;
|
||||
},
|
||||
|
||||
_addOutput: function (line) {
|
||||
if (this.truncate) {
|
||||
// Only replace single leading linebreak in the line after
|
||||
// -%> tag -- this is the single, trailing linebreak
|
||||
// after the tag that the truncation mode replaces
|
||||
// Handle Win / Unix / old Mac linebreaks -- do the \r\n
|
||||
// combo first in the regex-or
|
||||
line = line.replace(/^(?:\r\n|\r|\n)/, '');
|
||||
this.truncate = false;
|
||||
}
|
||||
else if (this.opts.rmWhitespace) {
|
||||
// rmWhitespace has already removed trailing spaces, just need
|
||||
// to remove linebreaks
|
||||
line = line.replace(/^\n/, '');
|
||||
}
|
||||
if (!line) {
|
||||
return line;
|
||||
}
|
||||
|
||||
// Preserve literal slashes
|
||||
line = line.replace(/\\/g, '\\\\');
|
||||
|
||||
// Convert linebreaks
|
||||
line = line.replace(/\n/g, '\\n');
|
||||
line = line.replace(/\r/g, '\\r');
|
||||
|
||||
// Escape double-quotes
|
||||
// - this will be the delimiter during execution
|
||||
line = line.replace(/"/g, '\\"');
|
||||
this.source += ' ; __append("' + line + '")' + '\n';
|
||||
},
|
||||
|
||||
scanLine: function (line) {
|
||||
var self = this;
|
||||
var d = this.opts.delimiter;
|
||||
var newLineCount = 0;
|
||||
|
||||
function _addOutput() {
|
||||
if (self.truncate) {
|
||||
// Only replace single leading linebreak in the line after
|
||||
// -%> tag -- this is the single, trailing linebreak
|
||||
// after the tag that the truncation mode replaces
|
||||
// Handle Win / Unix / old Mac linebreaks -- do the \r\n
|
||||
// combo first in the regex-or
|
||||
line = line.replace(/^(?:\r\n|\r|\n)/, '');
|
||||
self.truncate = false;
|
||||
}
|
||||
else if (self.opts.rmWhitespace) {
|
||||
// rmWhitespace has already removed trailing spaces, just need
|
||||
// to remove linebreaks
|
||||
line = line.replace(/^\n/, '');
|
||||
}
|
||||
if (!line) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Preserve literal slashes
|
||||
line = line.replace(/\\/g, '\\\\');
|
||||
|
||||
// Convert linebreaks
|
||||
line = line.replace(/\n/g, '\\n');
|
||||
line = line.replace(/\r/g, '\\r');
|
||||
|
||||
// Escape double-quotes
|
||||
// - this will be the delimiter during execution
|
||||
line = line.replace(/"/g, '\\"');
|
||||
self.source += ' ; __append("' + line + '")' + '\n';
|
||||
}
|
||||
|
||||
newLineCount = (line.split('\n').length - 1);
|
||||
|
||||
switch (line) {
|
||||
@@ -722,7 +747,7 @@ Template.prototype = {
|
||||
case '-' + d + '>':
|
||||
case '_' + d + '>':
|
||||
if (this.mode == Template.modes.LITERAL) {
|
||||
_addOutput();
|
||||
this._addOutput(line);
|
||||
}
|
||||
|
||||
this.mode = null;
|
||||
@@ -758,13 +783,13 @@ Template.prototype = {
|
||||
break;
|
||||
// Literal <%% mode, append as raw output
|
||||
case Template.modes.LITERAL:
|
||||
_addOutput();
|
||||
this._addOutput(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// In string mode, just add the output
|
||||
else {
|
||||
_addOutput();
|
||||
this._addOutput(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user