Example usage for com.google.common.html.types UncheckedConversions safeHtmlFromStringKnownToSatisfyTypeContract

List of usage examples for com.google.common.html.types UncheckedConversions safeHtmlFromStringKnownToSatisfyTypeContract

Introduction

In this page you can find the example usage for com.google.common.html.types UncheckedConversions safeHtmlFromStringKnownToSatisfyTypeContract.

Prototype

public static SafeHtml safeHtmlFromStringKnownToSatisfyTypeContract(String html) 

Source Link

Document

Converts a String into a SafeHtml.

Usage

From source file:com.google.template.soy.data.SanitizedContent.java

/**
 * Converts a Soy {@link SanitizedContent} of kind HTML into a {@link SafeHtml}.
 *
 * @throws IllegalStateException if this SanitizedContent's content kind is not
 *     {@link ContentKind#HTML}./*from  ww  w.j a v a  2  s.c  o  m*/
 */
public SafeHtml toSafeHtml() {
    Preconditions.checkState(getContentKind() == ContentKind.HTML,
            "toSafeHtml() only valid for SanitizedContent of kind HTML, is: %s", getContentKind());
    return UncheckedConversions.safeHtmlFromStringKnownToSatisfyTypeContract(getContent());
}

From source file:com.google.template.soy.data.SanitizedContent.java

/**
 * Converts a Soy {@link SanitizedContent} of kind HTML into a {@link SafeHtmlProto}.
 *
 * @throws IllegalStateException if this SanitizedContent's content kind is not
 *     {@link ContentKind#HTML}./*from w w w  . j a v  a2s.c  o m*/
 */
public SafeHtmlProto toSafeHtmlProto() {
    Preconditions.checkState(getContentKind() == ContentKind.HTML,
            "toSafeHtmlProto() only valid for SanitizedContent of kind HTML, is: %s", getContentKind());
    return SafeHtmls.toProto(UncheckedConversions.safeHtmlFromStringKnownToSatisfyTypeContract(getContent()));
}