Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// module dependencies
const yaml = require('js-yaml');
const mustache = require('mustache');
const createError = require('@pai/utils/error');
const hived = require('@pai/middlewares/v2/hived');
const launcherConfig = require('@pai/config/launcher');
const protocolSchema = require('@pai/config/v2/protocol');
const mustacheWriter = new mustache.Writer();
const prerequisiteTypes = [
'script',
'output',
'data',
'dockerimage',
];
const prerequisiteFields = [
'script',
'output',
'data',
'dockerImage',
];
* under the License.
*/
import { Writer } from 'mustache';
import chrome from 'ui/chrome';
import { metadata } from 'ui/metadata';
import {
DOC_LINK_VERSION,
ELASTIC_WEBSITE_URL,
documentationLinks
} from 'ui/documentation_links/documentation_links';
const TEMPLATE_TAGS = ['{', '}'];
// Can not use 'Mustache' since its a global object
const mustacheWriter = new Writer();
// do not html escape output
mustacheWriter.escapedValue = function escapedValue(token, context) {
const value = context.lookup(token[1]);
if (value != null) {
return value;
}
};
export function replaceTemplateStrings(text, params = {}) {
const variables = {
// '{' and '}' can not be used in template since they are used as template tags.
// Must use '{curlyOpen}'' and '{curlyClose}'
curlyOpen: '{',
curlyClose: '}',
config: {
cloud: {
* under the License.
*/
import { Writer } from 'mustache';
import chrome from 'ui/chrome';
import { metadata } from 'ui/metadata';
import {
DOC_LINK_VERSION,
ELASTIC_WEBSITE_URL,
documentationLinks
} from 'ui/documentation_links/documentation_links';
const TEMPLATE_TAGS = ['{', '}'];
// Can not use 'Mustache' since its a global object
const mustacheWriter = new Writer();
// do not html escape output
mustacheWriter.escapedValue = function escapedValue(token, context) {
const value = context.lookup(token[1]);
if (value != null) {
return value;
}
};
export function replaceTemplateStrings(text, params = {}) {
const variables = {
// '{' and '}' can not be used in template since they are used as template tags.
// Must use '{curlyOpen}'' and '{curlyClose}'
curlyOpen: '{',
curlyClose: '}',
config: {
cloud: {
return micromustache_compiledTag_renderer.render(obj)
}
function micromustache_render(obj) {
const renderer = compile(
'Hi, My name is {{name}}! I am {{age}} years old and live in {{cities.1}}. foo is {{nested.foo}}.'
)
return renderer.render(obj)
}
function micromustache_renderTag(obj) {
const renderer = compileTag()`Hi, My name is ${'name'}! I am ${'age'} years old and live in ${'cities.1'}. foo is ${'nested.foo'}.`
return renderer.render(obj)
}
const mustache_writer = new mustache.Writer()
const mustache_compile_tokens = mustache_writer.parse(
'Hi, My name is {{name}}! I am {{age}} years old and live in {{cities.1}}. foo is {{nested.foo}}.'
)
function mustache_compile(obj) {
return mustache_writer.renderTokens(mustache_compile_tokens, new mustache.Context(obj))
}
function mustache_render(obj) {
mustache.clearCache()
return mustache.render(
'Hi, My name is {{name}}! I am {{age}} years old and live in {{cities.1}}. foo is {{nested.foo}}.',
obj
)
}
// Fast but doesn't work in CSP environments https://github.com/wycats/handlebars.js/issues/1443
{textPre ? <p>{textPre}</p> : null}
{commands ? (
// TODO: Increase overflowHeight when https://github.com/elastic/eui/issues/2435 is fixed
// or be smarter with setting this number before release
{replaceTemplateStrings(commands.trim())}
) : null}
),
}))}
/>
);
// Setup for replacing template variables in install instructions
const mustacheWriter = new Writer();
// do not html escape output
// @ts-ignore
mustacheWriter.escapedValue = function escapedValue(token, context) {
const value = context.lookup(token[1]);
if (value != null) {
return value;
}
};
// Configure available variable values
export function replaceTemplateStrings(text: string = '') {
const variables = {
config: {
enrollmentToken: 'sometesttoken',
},
const mustache = require('mustache')
const writer = new mustache.Writer()
const mustacheCompileTokens = writer.parse(
'Hi, My name is {{name}}! I am {{age}} years old and live in {{cities.1}}. In {{cities.1}}, foo is {{nested.foo}}. My favorite book is {{books.0.name}} by {{books.0.author}}. ({{books.0.year}}) is not defined.'
)
function compiled(obj) {
return writer.renderTokens(mustacheCompileTokens, new mustache.Context(obj))
}
function render(obj) {
mustache.clearCache()
return mustache.render(
'Hi, My name is {{name}}! I am {{age}} years old and live in {{cities.1}}. In {{cities.1}}, foo is {{nested.foo}}. My favorite book is {{books.0.name}} by {{books.0.author}}. ({{books.0.year}}) is not defined.',
obj
)
}