def __new__(cls, *items): output = [] output.append(u'<ul class="helpList">') for item in items: output.extend([u'<li>', unicode(item), u'</li>']) output.append(u'</ul>') return SafeUnicode.__new__(cls, u''.join(output))
def __new__(cls, value): # Force input to be Unicode if not already. if isinstance(value, str): value = value.decode(_ASSUMED_ENCODING) # Define the HTML-encoded version of this value # that will be used if this string is substituted # directly into an HTML template. s = SafeUnicode.__new__(cls, u'<span class="splunk-tokensafe" data-value=' + quoteattr(value.encode(_ASSUMED_ENCODING)) + u'></span>' ) # Keep the original value for further processing # in case a token-aware tag receives a TokenSafeString # as an attribute. s.value = value return s