本文整理汇总了TypeScript中underscore.escape函数的典型用法代码示例。如果您正苦于以下问题:TypeScript escape函数的具体用法?TypeScript escape怎么用?TypeScript escape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了escape函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: imageLink
// Render a name + download link of an image
function imageLink(data: ImageData): string {
let name = '',
{file, fileType, imgnm} = data
const m = imgnm.match(/^(.*)\.\w{3,4}$/)
if (m) {
name = m[1]
}
const fullName = escape(imgnm),
tooLong = name.length >= 38
if (tooLong) {
imgnm = escape(name.slice(0, 30))
+ '(…)'
+ escape(sourceExtension(fileType))
}
const attrs: ElementAttributes = {
href: sourcePath(data),
rel: 'nofollow',
download: fullName
}
if (tooLong) {
attrs['title'] = fullName
}
return parseHTML
`<a ${parseAttributes(attrs)}>
${imgnm}
</a>`
}
开发者ID:Soreil,项目名称:meguca,代码行数:28,代码来源:image.ts
示例2: resolveName
// Determine the name and tripcode combination to render
function resolveName(data: PostData): string {
let html = ''
const {trip, name, auth} = data
if (name || !trip) {
if (name) {
html += escape(name)
} else {
html += lang.anon
}
if (trip) {
html += ' '
}
}
if (trip) {
html += `<code>${escape(trip)}</code>`
}
if (auth) { // Render staff title
let alias: string
if (auth in config.staff.classes) {
alias = config.staff.classes[auth].alias
} else {
alias = auth
}
html += ` ## ${alias}`
}
return html
}
开发者ID:Soreil,项目名称:meguca,代码行数:28,代码来源:header.ts
示例3: createListElement
private createListElement(data: CategoryFacetData) {
return `<li class="coveo-category-facet-value">
<label class="coveo-category-facet-value-label">
<span title="${escape(data.value)}" class="coveo-category-facet-value-caption">${escape(data.value)}</span>
<span class="coveo-category-facet-value-count">${data.count}</span>
</label>
</li>`;
}
开发者ID:coveo,项目名称:search-ui,代码行数:8,代码来源:CategoryFacetTemplates.ts
示例4: expect
it should replace this queryTag by the querySearched while escaping the tags`, () => {
const customMessage: string = `<div><a href="${queryTag}"></a></div>`;
test = Mock.optionsComponentSetup<QuerySummary, IQuerySummaryOptions>(QuerySummary, {
enableNoResultsFoundMessage: true,
noResultsFoundMessage: customMessage
});
test.env.queryStateModel.get = () => 'querySearched';
Simulate.query(test.env, { results: FakeResults.createFakeResults(0) });
const highlightedText = '<span class="coveo-highlight">querySearched</span>';
const parsedCustomMessage: string = `${escape('<div><a href=')}"${highlightedText}"${escape('></a></div>')}`;
expect(getCustomMessageElement().innerHTML).toBe(parsedCustomMessage);
});
开发者ID:coveo,项目名称:search-ui,代码行数:14,代码来源:QuerySummaryTest.ts
示例5: parseWord
// Convert a word to it's appropriate HTML representation
function parseWord(word: string, data: PostData): string {
// `[spoiler]` and `[/spoiler]` are treated the same way. You can't nest
// them.
const split = word.split(/\[\/?spoiler]/i)
let html = ''
for (let i = 0; i < split.length; i++) {
// Insert spoiler tags
if (i % 2) {
html += `<${data.state[2]++ % 2 ? '/' : ''}del>`
// TODO: Do we need special logic for postForms here?
}
const bit = split[i]
if (/^>>\d+$/.test(bit)) {
// Post links
html += parsePostLink(bit, data.links)
} else if (/^>>>\/\w+\//.test(bit)) {
// Internal and custom reference URLs
html += parseReference(bit)
} else if (/^https?:\/\/[^-A-Za-z0-9+&@#/%?=~_]$/.test(bit)) {
// Generic URLs
html += parseURL(bit)
} else if (/<strong>.+<\/strong>/.test(bit)) {
// Hash command results. Already verified server-side.
html += bit
} else {
html += escape(bit)
}
}
return html
}
开发者ID:Soreil,项目名称:meguca,代码行数:33,代码来源:body.ts
示例6: renderHeader
export function renderHeader(data: PostData): string {
const {id, op, subject} = data,
postURL = renderPostURL(id)
return parseHTML
`<header>
<input type="checkbox" class="postCheckbox">
${subject ? `<h3>ă${escape(data.subject)}ă</h3>` : ''}
${renderName(data)}
${renderTime(data.time)}
<nav>
<a href="${postURL}" class="history">
No.
</a>
<a href="${postURL}" class="quote">
${id.toString()}
</a>
</nav>
</header>
<span class="oi control" data-glyph="chevron-bottom"></span>`
}
开发者ID:Soreil,项目名称:meguca,代码行数:20,代码来源:header.ts
示例7: function
var errorFn = function(response:any) {
// Update model state
self.model.state = "DISABLED";
// Display error message
var msg = "<p>The feed cannot be deleted at this time.</p><p>";
msg += angular.isString(response.data.message) ? _.escape(response.data.message) : "Please try again later.";
msg += "</p>";
$mdDialog.hide();
$mdDialog.show(
$mdDialog.alert()
.ariaLabel("Error deleting feed")
.clickOutsideToClose(true)
.htmlContent(msg)
.ok("Got it!")
.parent(document.body)
.title("Error deleting feed")
);
};
开发者ID:prashanthc97,项目名称:kylo,代码行数:20,代码来源:FeedDetailsController.ts
示例8: sanitizeQuery
private static sanitizeQuery(query: IQuery) {
return query.q ? escape(query.q.trim()) : '';
}
开发者ID:coveo,项目名称:search-ui,代码行数:3,代码来源:QuerySummaryUtils.ts
示例9: function
fillHeader: function (headerDiv: any, header: any) {
headerDiv.innerHTML = _.escape(header.value);
},
开发者ID:prashanthc97,项目名称:kylo,代码行数:3,代码来源:FattableService.ts
注:本文中的underscore.escape函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论