當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore.escape函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。