How to use Eq method of html Package

Best K6 code snippet using html.Eq

template.go

Source:template.go Github

copy

Full Screen

1package webapp2import (3 "github.com/skygeario/skygear-server/pkg/core/config"4 "github.com/skygeario/skygear-server/pkg/core/template"5)6const (7 // Components8 TemplateItemTypeAuthUIHTMLHeadHTML config.TemplateItemType = "auth_ui_html_head.html"9 TemplateItemTypeAuthUIHeaderHTML config.TemplateItemType = "auth_ui_header.html"10 TemplateItemTypeAuthUIFooterHTML config.TemplateItemType = "auth_ui_footer.html"11 // Interaction entrypoints12 TemplateItemTypeAuthUILoginHTML config.TemplateItemType = "auth_ui_login.html"13 TemplateItemTypeAuthUISignupHTML config.TemplateItemType = "auth_ui_signup.html"14 TemplateItemTypeAuthUIPromoteHTML config.TemplateItemType = "auth_ui_promote.html"15 // Interaction steps16 // nolint: gosec17 TemplateItemTypeAuthUIEnterPasswordHTML config.TemplateItemType = "auth_ui_enter_password.html"18 // nolint: gosec19 TemplateItemTypeAuthUICreatePasswordHTML config.TemplateItemType = "auth_ui_create_password.html"20 TemplateItemTypeAuthUIOOBOTPHTML config.TemplateItemType = "auth_ui_oob_otp_html"21 TemplateItemTypeAuthUIEnterLoginIDHTML config.TemplateItemType = "auth_ui_enter_login_id.html"22 // Forgot Password23 // nolint: gosec24 TemplateItemTypeAuthUIForgotPasswordHTML config.TemplateItemType = "auth_ui_forgot_password.html"25 // nolint: gosec26 TemplateItemTypeAuthUIForgotPasswordSuccessHTML config.TemplateItemType = "auth_ui_forgot_password_success.html"27 // nolint: gosec28 TemplateItemTypeAuthUIResetPasswordHTML config.TemplateItemType = "auth_ui_reset_password.html"29 // nolint: gosec30 TemplateItemTypeAuthUIResetPasswordSuccessHTML config.TemplateItemType = "auth_ui_reset_password_success.html"31 // Logout32 TemplateItemTypeAuthUILogoutHTML config.TemplateItemType = "auth_ui_logout.html"33 // Settings34 TemplateItemTypeAuthUISettingsHTML config.TemplateItemType = "auth_ui_settings.html"35 TemplateItemTypeAuthUISettingsIdentityHTML config.TemplateItemType = "auth_ui_settings_identity.html"36)37var TemplateAuthUIHTMLHeadHTML = template.Spec{38 Type: TemplateItemTypeAuthUIHTMLHeadHTML,39 IsHTML: true,40 Default: `41{{ define "auth_ui_html_head.html" }}42<head>43<title>{{ .app_name }}</title>44<meta name="viewport" content="width=device-width, initial-scale=1">45<link rel="stylesheet" href="{{ .x_static_asset_url_prefix }}/css/main.css">46<script src="{{ .x_static_asset_url_prefix}}/js/main.js"></script>47{{ if .x_css }}48<style>49{{ .x_css }}50</style>51{{ end }}52</head>53{{ end }}54`,55}56var TemplateAuthUIHeaderHTML = template.Spec{57 Type: TemplateItemTypeAuthUIHeaderHTML,58 IsHTML: true,59 Default: `60{{ define "auth_ui_header.html" }}61{{ if .logo_uri }}62<div class="logo" style="background-image: url('{{ .logo_uri }}'); background-position: center; background-size: contain; background-repeat: no-repeat"></div>63{{ else }}64<div class="logo"></div>65{{ end }}66{{ end }}67`,68}69var TemplateAuthUIFooterHTML = template.Spec{70 Type: TemplateItemTypeAuthUIFooterHTML,71 IsHTML: true,72 Default: `73{{ define "auth_ui_footer.html" }}74<div class="skygear-logo"></div>75{{ end }}76`,77}78const defineError = `79{{ define "ERROR" }}80{{ if .x_error }}81<ul class="errors">82 {{ if eq .x_error.reason "ValidationFailed" }}83 {{ range .x_error.info.causes }}84 {{ if and (eq .kind "Required") (eq .pointer "/x_login_id" ) }}85 <li class="error-txt">{{ localize "error-login-id-required" $.x_login_page_text_login_id_variant }}</li>86 {{ else if and (eq .kind "Required") (eq .pointer "/x_password" ) }}87 <li class="error-txt">{{ localize "error-password-or-code-required" }}</li>88 {{ else if and (eq .kind "Required") (eq .pointer "/x_calling_code" ) }}89 <li class="error-txt">{{ localize "error-calling-code-required" }}</li>90 {{ else if and (eq .kind "Required") (eq .pointer "/x_national_number" ) }}91 <li class="error-txt">{{ localize "error-phone-number-required" }}</li>92 {{ else if and (eq .kind "StringFormat") (eq .details.format "phone" ) }}93 <li class="error-txt">{{ localize "error-phone-number-format" }}</li>94 {{ else if and (eq .kind "StringFormat") (eq .details.format "email") }}95 <li class="error-txt">{{ localize "error-invalid-email" }}</li>96 {{ else if and (eq .kind "StringFormat") (eq .details.format "username") }}97 <li class="error-txt">{{ localize "error-invalid-username" }}</li>98 {{ else }}99 <li class="error-txt">{{ .message }}</li>100 {{ end }}101 {{ end }}102 {{ else if eq .x_error.reason "InvalidCredentials" }}103 <li class="error-txt">{{ localize "error-invalid-credentials" }}</li>104 {{ else if eq .x_error.reason "PasswordPolicyViolated" }}105 <!-- This error is handled differently -->106 {{ else if eq .x_error.reason "PasswordResetFailed" }}107 <li class="error-txt">{{ localize "error-password-reset-failed" }}</li>108 {{ else if eq .x_error.reason "DuplicatedIdentity" }}109 <li class="error-txt">{{ localize "error-duplicated-identity" }}</li>110 {{ else if eq .x_error.reason "InvalidIdentityRequest" }}111 <li class="error-txt">{{ localize "error-remove-last-identity" }}</li>112 {{ else }}113 <li class="error-txt">{{ .x_error.message }}</li>114 {{ end }}115</ul>116{{ end }}117{{ end }}118`119// nolint: gosec120const definePasswordPolicy = `121{{ define "PASSWORD_POLICY" }}122{{ if .x_password_policies }}123<ul>124{{ range .x_password_policies }}125 {{ if eq .kind "PasswordTooShort" }}126 <li class="primary-txt password-policy length {{ template "PASSWORD_POLICY_CLASS" . }}" data-min-length="{{ .min_length}}">127 {{ localize "password-policy-minimum-length" .min_length }}128 </li>129 {{ end }}130 {{ if eq .kind "PasswordUppercaseRequired" }}131 <li class="primary-txt password-policy uppercase {{ template "PASSWORD_POLICY_CLASS" . }}">132 {{ localize "password-policy-uppercase" }}133 </li>134 {{ end }}135 {{ if eq .kind "PasswordLowercaseRequired" }}136 <li class="primary-txt password-policy lowercase {{ template "PASSWORD_POLICY_CLASS" . }}">137 {{ localize "password-policy-lowercase" }}138 </li>139 {{ end }}140 {{ if eq .kind "PasswordDigitRequired" }}141 <li class="primary-txt password-policy digit {{ template "PASSWORD_POLICY_CLASS" . }}">142 {{ localize "password-policy-digit" }}143 </li>144 {{ end }}145 {{ if eq .kind "PasswordSymbolRequired" }}146 <li class="primary-txt password-policy symbol {{ template "PASSWORD_POLICY_CLASS" . }}">147 {{ localize "password-policy-symbol" }}148 </li>149 {{ end }}150 {{ if eq .kind "PasswordContainingExcludedKeywords" }}151 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">152 {{ localize "password-policy-banned-words" }}153 </li>154 {{ end }}155 {{ if eq .kind "PasswordBelowGuessableLevel" }}156 {{ if eq .min_level 1.0 }}157 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">158 {{ localize "password-policy-guessable-level-1" }}159 </li>160 {{ end }}161 {{ if eq .min_level 2.0 }}162 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">163 {{ localize "password-policy-guessable-level-2" }}164 </li>165 {{ end }}166 {{ if eq .min_level 3.0 }}167 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">168 {{ localize "password-policy-guessable-level-3" }}169 </li>170 {{ end }}171 {{ if eq .min_level 4.0 }}172 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">173 {{ localize "password-policy-guessable-level-4" }}174 </li>175 {{ end }}176 {{ if eq .min_level 5.0 }}177 <li class="primary-txt password-policy {{ template "PASSWORD_POLICY_CLASS" . }}">178 {{ localize "password-policy-guessable-level-5" }}179 </li>180 {{ end }}181 {{ end }}182{{ end }}183</ul>184{{ end }}185{{ end }}186`187// nolint: gosec188const definePasswordPolicyClass = `189{{- define "PASSWORD_POLICY_CLASS" -}}190{{- if .x_error_is_password_policy_violated -}}191{{- if .x_is_violated -}}192violated193{{- else -}}194passed195{{- end -}}196{{- end -}}197{{- end -}}198`199var defines = []string{200 defineError,201 definePasswordPolicy,202 definePasswordPolicyClass,203}204var components = []config.TemplateItemType{205 TemplateItemTypeAuthUIHTMLHeadHTML,206 TemplateItemTypeAuthUIHeaderHTML,207 TemplateItemTypeAuthUIFooterHTML,208}209var TemplateAuthUILoginHTML = template.Spec{210 Type: TemplateItemTypeAuthUILoginHTML,211 IsHTML: true,212 Translation: TemplateItemTypeAuthUITranslationJSON,213 Defines: defines,214 Components: components,215 Default: `<!DOCTYPE html>216<html>217{{ template "auth_ui_html_head.html" . }}218<body class="page">219 <div class="content">220 {{ template "auth_ui_header.html" . }}221 <div class="authorize-form">222 <div class="authorize-idp-section">223 {{ range .x_identity_candidates }}224 {{ if eq .type "oauth" }}225 <form class="authorize-idp-form" method="post" novalidate>226 {{ $.csrfField }}227 <button class="btn sso-btn {{ .provider_type }}" type="submit" name="x_idp_id" value="{{ .provider_alias }}" data-form-xhr="false">228 {{- if eq .provider_type "apple" -}}229 {{ localize "sign-in-apple" }}230 {{- end -}}231 {{- if eq .provider_type "google" -}}232 {{ localize "sign-in-google" }}233 {{- end -}}234 {{- if eq .provider_type "facebook" -}}235 {{ localize "sign-in-facebook" }}236 {{- end -}}237 {{- if eq .provider_type "linkedin" -}}238 {{ localize "sign-in-linkedin" }}239 {{- end -}}240 {{- if eq .provider_type "azureadv2" -}}241 {{ localize "sign-in-azureadv2" }}242 {{- end -}}243 </button>244 </form>245 {{ end }}246 {{ end }}247 </div>248 {{ $has_oauth := false }}249 {{ $has_login_id := false }}250 {{ range .x_identity_candidates }}251 {{ if eq .type "oauth" }}252 {{ $has_oauth = true }}253 {{ end }}254 {{ if eq .type "login_id" }}255 {{ $has_login_id = true }}256 {{ end }}257 {{ end }}258 {{ if $has_oauth }}{{ if $has_login_id }}259 <div class="primary-txt sso-loginid-separator">{{ localize "sso-login-id-separator" }}</div>260 {{ end }}{{ end }}261 {{ template "ERROR" . }}262 <form class="authorize-loginid-form" method="post" novalidate>263 {{ $.csrfField }}264 {{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "phone" }}{{ if .x_login_page_login_id_has_phone }}265 <div class="phone-input">266 <select class="input select primary-txt" name="x_calling_code">267 {{ range .x_calling_codes }}268 <option269 value="{{ . }}"270 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}271 selected272 {{ end }}{{ end }}273 >274 +{{ . }}275 </option>276 {{ end }}277 </select>278 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">279 </div>280 {{ end }}{{ end }}{{ end }}281 {{ if .x_login_id_input_type }}{{ if not (eq .x_login_id_input_type "phone") }}{{ if (not (eq .x_login_page_text_login_id_variant "none")) }}282 <input class="input text-input primary-txt" type="{{ .x_login_page_text_login_id_input_type }}" name="x_login_id" placeholder="{{ localize "login-id-placeholder" .x_login_page_text_login_id_variant }}">283 {{ end }}{{ end }}{{ end }}284 {{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "phone" }}{{ if (not (eq .x_login_page_text_login_id_variant "none")) }}285 <a class="link align-self-flex-start" href="{{ call .MakeURLWithQuery "x_login_id_input_type" .x_login_page_text_login_id_input_type }}">{{ localize "use-text-login-id-description" .x_login_page_text_login_id_variant }}</a>286 {{ end }}{{ end }}{{ end }}287 {{ if .x_login_id_input_type }}{{ if not (eq .x_login_id_input_type "phone") }}{{ if .x_login_page_login_id_has_phone }}288 <a class="link align-self-flex-start" href="{{ call .MakeURLWithQuery "x_login_id_input_type" "phone" }}">{{ localize "use-phone-login-id-description" }}</a>289 {{ end }}{{ end }}{{ end }}290 <div class="link">291 <span class="primary-text">{{ localize "signup-button-hint" }}</span>292 <a href="{{ call .MakeURLWithPathWithoutX "/signup" }}">{{ localize "signup-button-label" }}</a>293 </div>294 {{ if .x_password_authenticator_enabled }}295 <a class="link align-self-flex-start" href="{{ call .MakeURLWithPathWithoutX "/forgot_password" }}">{{ localize "forgot-password-button-label" }}</a>296 {{ end }}297 {{ if or .x_login_page_login_id_has_phone (not (eq .x_login_page_text_login_id_variant "none")) }}298 <button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>299 {{ end }}300 </form>301 </div>302 {{ template "auth_ui_footer.html" . }}303 </div>304</body>305</html>306`,307}308var TemplateAuthUIEnterPasswordHTML = template.Spec{309 Type: TemplateItemTypeAuthUIEnterPasswordHTML,310 IsHTML: true,311 Translation: TemplateItemTypeAuthUITranslationJSON,312 Defines: defines,313 Components: components,314 Default: `<!DOCTYPE html>315<html>316{{ template "auth_ui_html_head.html" . }}317<body class="page">318<div class="content">319{{ template "auth_ui_header.html" . }}320<form class="simple-form vertical-form form-fields-container" method="post" novalidate>321{{ $.csrfField }}322<div class="nav-bar">323 <button class="btn back-btn" type="button" title="{{ localize "back-button-title" }}"></button>324 <div class="login-id primary-txt">325 {{ if .x_national_number }}326 +{{ .x_calling_code}} {{ .x_national_number }}327 {{ else }}328 {{ .x_login_id }}329 {{ end }}330 </div>331</div>332<div class="title primary-txt">{{ localize "enter-password-page-title" }}</div>333{{ template "ERROR" . }}334<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">335<input id="password" class="input text-input primary-txt" type="password" name="x_password" placeholder="{{ localize "password-placeholder" }}">336<button class="btn secondary-btn password-visibility-btn show-password" type="button">{{ localize "show-password" }}</button>337<button class="btn secondary-btn password-visibility-btn hide-password" type="button">{{ localize "hide-password" }}</button>338{{ if .x_password_authenticator_enabled }}339<a class="link align-self-flex-start" href="{{ call .MakeURLWithPathWithoutX "/forgot_password" }}">{{ localize "forgot-password-button-label--enter-password-page" }}</a>340{{ end }}341<button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>342</form>343{{ template "auth_ui_footer.html" . }}344</div>345</body>346</html>347`,348}349var TemplateAuthUIOOBOTPHTML = template.Spec{350 Type: TemplateItemTypeAuthUIOOBOTPHTML,351 IsHTML: true,352 Translation: TemplateItemTypeAuthUITranslationJSON,353 Defines: defines,354 Components: components,355 Default: `<!DOCTYPE html>356<html>357{{ template "auth_ui_html_head.html" . }}358<body class="page">359<div class="content">360{{ template "auth_ui_header.html" . }}361<div class="simple-form vertical-form form-fields-container">362<div class="nav-bar">363 <button class="btn back-btn" type="button" title="{{ localize "back-button-title" }}"></button>364</div>365{{ if eq .x_login_id_input_type "phone" }}366<div class="title primary-txt">{{ localize "oob-otp-page-title--sms" }}</div>367{{ end }}368{{ if not (eq .x_login_id_input_type "phone") }}369<div class="title primary-txt">{{ localize "oob-otp-page-title--email" }}</div>370{{ end }}371{{ template "ERROR" . }}372{{ if eq .x_login_id_input_type "phone" }}373<div class="description primary-txt">{{ localize "oob-otp-description--sms" .x_oob_otp_code_length .x_calling_code .x_national_number }}</div>374{{ end }}375{{ if not (eq .x_login_id_input_type "phone") }}376<div class="description primary-txt">{{ localize "oob-otp-description--email" .x_oob_otp_code_length .x_login_id }}</div>377{{ end }}378<form class="vertical-form form-fields-container" method="post" novalidate>379{{ $.csrfField }}380<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">381<input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_password" placeholder="{{ localize "oob-otp-placeholder" }}">382<button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>383</form>384<form class="link oob-otp-trigger-form" method="post" novalidate>385{{ $.csrfField }}386<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">387<span class="primary-txt">{{ localize "oob-otp-resend-button-hint" }}</span>388<button id="resend-button" class="anchor" type="submit" name="trigger" value="true"389 data-cooldown="{{ .x_oob_otp_code_send_cooldown }}"390 data-label="{{ localize "oob-otp-resend-button-label" }}"391 data-label-unit="{{ localize "oob-otp-resend-button-label--unit" }}">{{ localize "oob-otp-resend-button-label" }}</button>392</form>393</div>394{{ template "auth_ui_footer.html" . }}395</div>396</body>397</html>398`,399}400var TemplateAuthUIEnterLoginIDHTML = template.Spec{401 Type: TemplateItemTypeAuthUIEnterLoginIDHTML,402 IsHTML: true,403 Translation: TemplateItemTypeAuthUITranslationJSON,404 Defines: defines,405 Components: components,406 Default: `<!DOCTYPE html>407<html>408{{ template "auth_ui_html_head.html" . }}409<body class="page">410<div class="content">411{{ template "auth_ui_header.html" . }}412<div class="simple-form vertical-form form-fields-container">413<div class="nav-bar">414 <button class="btn back-btn" type="button" title="{{ localize "back-button-title" }}"></button>415</div>416<div class="title primary-txt">417 {{ if .x_old_login_id_value }}418 {{ localize "enter-login-id-page-title--change" .x_login_id_key }}419 {{ else }}420 {{ localize "enter-login-id-page-title--add" .x_login_id_key }}421 {{ end }}422</div>423{{ template "ERROR" . }}424<form class="vertical-form form-fields-container" method="post" novalidate>425{{ $.csrfField }}426<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">427<input type="hidden" name="x_login_id_key" value="{{ .x_login_id_key }}">428<input type="hidden" name="x_login_id_type" value="{{ .x_login_id_type }}">429<input type="hidden" name="x_login_id_input_type" value="{{ .x_login_id_input_type }}">430<input type="hidden" name="x_old_login_id_value" value="{{ .x_old_login_id_value }}">431{{ if eq .x_login_id_input_type "phone" }}432<div class="phone-input">433 <select class="input select primary-txt" name="x_calling_code">434 {{ range .x_calling_codes }}435 <option436 value="{{ . }}"437 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}438 selected439 {{ end }}{{ end }}440 >441 +{{ . }}442 </option>443 {{ end }}444 </select>445 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">446</div>447{{ else }}448<input class="input text-input primary-txt" type="{{ .x_login_id_input_type }}" name="x_login_id" placeholder="{{ localize "login-id-placeholder" .x_login_id_type }}">449{{ end }}450<button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>451</form>452{{ if .x_old_login_id_value }}453<form class="enter-login-id-remove-form" method="post" novalidate>454{{ $.csrfField }}455<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">456<input type="hidden" name="x_login_id_key" value="{{ .x_login_id_key }}">457<input type="hidden" name="x_login_id_type" value="{{ .x_login_id_type }}">458<input type="hidden" name="x_login_id_input_type" value="{{ .x_login_id_input_type }}">459<input type="hidden" name="x_old_login_id_value" value="{{ .x_old_login_id_value }}">460<button class="anchor" type="submit" name="x_action" value="remove">{{ localize "disconnect-button-label" }}</button>461{{ end }}462</form>463</div>464{{ template "auth_ui_footer.html" . }}465</div>466</body>467</html>468`,469}470var TemplateAuthUIForgotPasswordHTML = template.Spec{471 Type: TemplateItemTypeAuthUIForgotPasswordHTML,472 IsHTML: true,473 Translation: TemplateItemTypeAuthUITranslationJSON,474 Defines: defines,475 Components: components,476 Default: `<!DOCTYPE html>477<html>478{{ template "auth_ui_html_head.html" . }}479<body class="page">480<div class="content">481{{ template "auth_ui_header.html" . }}482<form class="simple-form vertical-form form-fields-container" method="post" novalidate>483{{ $.csrfField }}484<div class="nav-bar">485 <button class="btn back-btn" type="button" title="{{ localize "back-button-title" }}"></button>486</div>487<div class="title primary-txt">{{ localize "forgot-password-page-title" }}</div>488{{ template "ERROR" . }}489{{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "phone" }}{{ if .x_login_page_login_id_has_phone }}490<div class="description primary-txt">{{ localize "forgot-password-phone-description" }}</div>491<div class="phone-input">492 <select class="input select primary-txt" name="x_calling_code">493 {{ range .x_calling_codes }}494 <option495 value="{{ . }}"496 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}497 selected498 {{ end }}{{ end }}499 >500 +{{ . }}501 </option>502 {{ end }}503 </select>504 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">505</div>506{{ end }}{{ end }}{{ end }}507{{ if .x_login_id_input_type }}{{ if (not (eq .x_login_id_input_type "phone")) }}{{ if or (eq .x_login_page_text_login_id_variant "email") (eq .x_login_page_text_login_id_variant "email_or_username") }}508<div class="description primary-txt">{{ localize "forgot-password-email-description" }}</div>509<input class="input text-input primary-txt" type="{{ .x_login_id_input_type }}" name="x_login_id" placeholder="{{ localize "email-placeholder" }}">510{{ end }}{{ end }}{{ end }}511{{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "phone" }}{{ if or (eq .x_login_page_text_login_id_variant "email") (eq .x_login_page_text_login_id_variant "email_or_username") }}512<a class="link align-self-flex-start" href="{{ call .MakeURLWithQuery "x_login_id_input_type" "email" }}">{{ localize "use-email-login-id-description" }}</a>513{{ end }}{{ end }}{{ end }}514{{ if .x_login_id_input_type }}{{ if eq .x_login_id_input_type "email" }}{{ if .x_login_page_login_id_has_phone }}515<a class="link align-self-flex-start" href="{{ call .MakeURLWithQuery "x_login_id_input_type" "phone" }}">{{ localize "use-phone-login-id-description" }}</a>516{{ end }}{{ end }}{{ end }}517{{ if or .x_login_page_login_id_has_phone (not (eq .x_login_page_text_login_id_variant "none")) }}518<button class="btn primary-btn submit-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>519{{ end }}520</form>521{{ template "auth_ui_footer.html" . }}522</div>523</body>524</html>525`,526}527var TemplateAuthUIForgotPasswordSuccessHTML = template.Spec{528 Type: TemplateItemTypeAuthUIForgotPasswordSuccessHTML,529 IsHTML: true,530 Translation: TemplateItemTypeAuthUITranslationJSON,531 Defines: defines,532 Components: components,533 Default: `<!DOCTYPE html>534<html>535{{ template "auth_ui_html_head.html" . }}536<body class="page">537<div class="content">538{{ template "auth_ui_header.html" . }}539<div class="simple-form vertical-form form-fields-container">540<div class="title primary-txt">{{ localize "forgot-password-success-page-title" }}</div>541{{ template "ERROR" . }}542<div class="description primary-txt">{{ localize "forgot-password-success-description" .x_login_id }}</div>543<a class="btn primary-btn align-self-flex-end" href="{{ call .MakeURLWithPathWithoutX "/login" }}">{{ localize "login-button-label--forgot-password-success-page" }}</a>544</div>545{{ template "auth_ui_footer.html" . }}546</div>547</body>548</html>549`,550}551var TemplateAuthUIResetPasswordHTML = template.Spec{552 Type: TemplateItemTypeAuthUIResetPasswordHTML,553 IsHTML: true,554 Translation: TemplateItemTypeAuthUITranslationJSON,555 Defines: defines,556 Components: components,557 Default: `<!DOCTYPE html>558<html>559{{ template "auth_ui_html_head.html" . }}560<body class="page">561<div class="content">562{{ template "auth_ui_header.html" . }}563<form class="simple-form vertical-form form-fields-container" method="post" novalidate>564{{ $.csrfField }}565<div class="title primary-txt">{{ localize "reset-password-page-title" }}</div>566{{ template "ERROR" . }}567<div class="description primary-txt">{{ localize "reset-password-description" }}</div>568<input id="password" data-password-policy-password="" class="input text-input primary-txt" type="password" name="x_password" placeholder="{{ localize "password-placeholder" }}">569<button class="btn secondary-btn password-visibility-btn show-password" type="button">{{ localize "show-password" }}</button>570<button class="btn secondary-btn password-visibility-btn hide-password" type="button">{{ localize "hide-password" }}</button>571{{ template "PASSWORD_POLICY" . }}572<button class="btn primary-btn submit-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>573</form>574{{ template "auth_ui_footer.html" . }}575</div>576</body>577</html>578`,579}580var TemplateAuthUIResetPasswordSuccessHTML = template.Spec{581 Type: TemplateItemTypeAuthUIResetPasswordSuccessHTML,582 IsHTML: true,583 Translation: TemplateItemTypeAuthUITranslationJSON,584 Defines: defines,585 Components: components,586 Default: `<!DOCTYPE html>587<html>588{{ template "auth_ui_html_head.html" . }}589<body class="page">590<div class="content">591{{ template "auth_ui_header.html" . }}592<div class="simple-form vertical-form form-fields-container">593<div class="title primary-txt">{{ localize "reset-password-success-page-title" }}</div>594{{ template "ERROR" . }}595<div class="description primary-txt">{{ localize "reset-password-success-description" .x_login_id }}</div>596</div>597{{ template "auth_ui_footer.html" . }}598</div>599</body>600</html>601`,602}603var TemplateAuthUISignupHTML = template.Spec{604 Type: TemplateItemTypeAuthUISignupHTML,605 IsHTML: true,606 Translation: TemplateItemTypeAuthUITranslationJSON,607 Defines: defines,608 Components: components,609 Default: `<!DOCTYPE html>610<html>611{{ template "auth_ui_html_head.html" . }}612<body class="page">613 <div class="content">614 {{ template "auth_ui_header.html" . }}615 <div class="authorize-form">616 <div class="authorize-idp-section">617 {{ range .x_identity_candidates }}618 {{ if eq .type "oauth" }}619 <form class="authorize-idp-form" method="post" novalidate>620 {{ $.csrfField }}621 <button class="btn sso-btn {{ .provider_type }}" type="submit" name="x_idp_id" value="{{ .provider_alias }}" data-form-xhr="false">622 {{- if eq .provider_type "apple" -}}623 {{ localize "sign-up-apple" }}624 {{- end -}}625 {{- if eq .provider_type "google" -}}626 {{ localize "sign-up-google" }}627 {{- end -}}628 {{- if eq .provider_type "facebook" -}}629 {{ localize "sign-up-facebook" }}630 {{- end -}}631 {{- if eq .provider_type "linkedin" -}}632 {{ localize "sign-up-linkedin" }}633 {{- end -}}634 {{- if eq .provider_type "azureadv2" -}}635 {{ localize "sign-up-azureadv2" }}636 {{- end -}}637 </button>638 </form>639 {{ end }}640 {{ end }}641 </div>642 {{ $has_oauth := false }}643 {{ $has_login_id := false }}644 {{ range .x_identity_candidates }}645 {{ if eq .type "oauth" }}646 {{ $has_oauth = true }}647 {{ end }}648 {{ if eq .type "login_id" }}649 {{ $has_login_id = true }}650 {{ end }}651 {{ end }}652 {{ if $has_oauth }}{{ if $has_login_id }}653 <div class="primary-txt sso-loginid-separator">{{ localize "sso-login-id-separator" }}</div>654 {{ end }}{{ end }}655 {{ template "ERROR" . }}656 <form class="authorize-loginid-form" method="post" novalidate>657 {{ $.csrfField }}658 <input type="hidden" name="x_login_id_key" value="{{ .x_login_id_key }}">659 {{ range .x_identity_candidates }}660 {{ if eq .type "login_id" }}{{ if eq .login_id_key $.x_login_id_key }}661 {{ if eq .login_id_type "phone" }}662 <div class="phone-input">663 <select class="input select primary-txt" name="x_calling_code">664 {{ range $.x_calling_codes }}665 <option666 value="{{ . }}"667 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}668 selected669 {{ end }}{{ end }}670 >671 +{{ . }}672 </option>673 {{ end }}674 </select>675 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">676 </div>677 {{ else }}678 <input class="input text-input primary-txt" type="{{ $.x_login_id_input_type }}" name="x_login_id" placeholder="{{ .login_id_type }}">679 {{ end }}680 {{ end }}{{ end }}681 {{ end }}682 {{ range .x_identity_candidates }}683 {{ if eq .type "login_id" }}{{ if not (eq .login_id_key $.x_login_id_key) }}684 <a class="link align-self-flex-start"685 href="{{ call $.MakeURLWithQuery "x_login_id_key" .login_id_key "x_login_id_input_type" .login_id_input_type}}">686 {{ localize "use-login-id-key" .login_id_key }}687 </a>688 {{ end }}{{ end }}689 {{ end }}690 <div class="link align-self-flex-start">691 <span class="primary-text">{{ localize "login-button-hint" }}</span>692 <a href="{{ call .MakeURLWithPathWithoutX "/login" }}">{{ localize "login-button-label" }}</a>693 </div>694 {{ if .x_password_authenticator_enabled }}695 <a class="link align-self-flex-start" href="{{ call .MakeURLWithPathWithoutX "/forgot_password" }}">{{ localize "forgot-password-button-label" }}</a>696 {{ end }}697 <button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">698 {{ localize "next-button-label" }}699 </button>700 </form>701 </div>702 {{ template "auth_ui_footer.html" . }}703 </div>704</body>705</html>706`,707}708var TemplateAuthUIPromoteHTML = template.Spec{709 Type: TemplateItemTypeAuthUIPromoteHTML,710 IsHTML: true,711 Translation: TemplateItemTypeAuthUITranslationJSON,712 Defines: defines,713 Components: components,714 Default: `<!DOCTYPE html>715<html>716{{ template "auth_ui_html_head.html" . }}717<body class="page">718 <div class="content">719 {{ template "auth_ui_header.html" . }}720 <div class="authorize-form">721 <div class="authorize-idp-section">722 {{ range .x_identity_candidates }}723 {{ if eq .type "oauth" }}724 <form class="authorize-idp-form" method="post" novalidate>725 {{ $.csrfField }}726 <button class="btn sso-btn {{ .provider_type }}" type="submit" name="x_idp_id" value="{{ .provider_alias }}" data-form-xhr="false">727 {{- if eq .provider_type "apple" -}}728 {{ localize "sign-up-apple" }}729 {{- end -}}730 {{- if eq .provider_type "google" -}}731 {{ localize "sign-up-google" }}732 {{- end -}}733 {{- if eq .provider_type "facebook" -}}734 {{ localize "sign-up-facebook" }}735 {{- end -}}736 {{- if eq .provider_type "linkedin" -}}737 {{ localize "sign-up-linkedin" }}738 {{- end -}}739 {{- if eq .provider_type "azureadv2" -}}740 {{ localize "sign-up-azureadv2" }}741 {{- end -}}742 </button>743 </form>744 {{ end }}745 {{ end }}746 </div>747 {{ $has_oauth := false }}748 {{ $has_login_id := false }}749 {{ range .x_identity_candidates }}750 {{ if eq .type "oauth" }}751 {{ $has_oauth = true }}752 {{ end }}753 {{ if eq .type "login_id" }}754 {{ $has_login_id = true }}755 {{ end }}756 {{ end }}757 {{ if $has_oauth }}{{ if $has_login_id }}758 <div class="primary-txt sso-loginid-separator">{{ localize "sso-login-id-separator" }}</div>759 {{ end }}{{ end }}760 {{ template "ERROR" . }}761 <form class="authorize-loginid-form" method="post" novalidate>762 {{ $.csrfField }}763 <input type="hidden" name="x_login_id_key" value="{{ .x_login_id_key }}">764 {{ range .x_identity_candidates }}765 {{ if eq .type "login_id" }}{{ if eq .login_id_key $.x_login_id_key }}766 {{ if eq .login_id_type "phone" }}767 <div class="phone-input">768 <select class="input select primary-txt" name="x_calling_code">769 {{ range $.x_calling_codes }}770 <option771 value="{{ . }}"772 {{ if $.x_calling_code }}{{ if eq $.x_calling_code . }}773 selected774 {{ end }}{{ end }}775 >776 +{{ . }}777 </option>778 {{ end }}779 </select>780 <input class="input text-input primary-txt" type="text" inputmode="numeric" pattern="[0-9]*" name="x_national_number" placeholder="{{ localize "phone-number-placeholder" }}">781 </div>782 {{ else }}783 <input class="input text-input primary-txt" type="{{ $.x_login_id_input_type }}" name="x_login_id" placeholder="{{ .login_id_type }}">784 {{ end }}785 {{ end }}{{ end }}786 {{ end }}787 {{ range .x_identity_candidates }}788 {{ if eq .type "login_id" }}{{ if not (eq .login_id_key $.x_login_id_key) }}789 <a class="link align-self-flex-start"790 href="{{ call $.MakeURLWithQuery "x_login_id_key" .login_id_key "x_login_id_input_type" .login_id_input_type}}">791 {{ localize "use-login-id-key" .login_id_key }}792 </a>793 {{ end }}{{ end }}794 {{ end }}795 <button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">796 {{ localize "next-button-label" }}797 </button>798 </form>799 </div>800 {{ template "auth_ui_footer.html" . }}801 </div>802</body>803</html>804`,805}806var TemplateAuthUICreatePasswordHTML = template.Spec{807 Type: TemplateItemTypeAuthUICreatePasswordHTML,808 IsHTML: true,809 Translation: TemplateItemTypeAuthUITranslationJSON,810 Defines: defines,811 Components: components,812 Default: `<!DOCTYPE html>813<html>814{{ template "auth_ui_html_head.html" . }}815<body class="page">816<div class="content">817{{ template "auth_ui_header.html" . }}818<form class="simple-form vertical-form form-fields-container" method="post" novalidate>819{{ $.csrfField }}820<input type="hidden" name="x_interaction_token" value="{{ .x_interaction_token }}">821<div class="nav-bar">822 <button class="btn back-btn" type="button" title="{{ "back-button-title" }}"></button>823 <div class="login-id primary-txt">824 {{ if .x_national_number }}825 +{{ .x_calling_code}} {{ .x_national_number }}826 {{ else }}827 {{ .x_login_id }}828 {{ end }}829 </div>830</div>831<div class="title primary-txt">{{ localize "create-password-page-title" }}</div>832{{ template "ERROR" . }}833<input id="password" data-password-policy-password="" class="input text-input primary-txt" type="password" name="x_password" placeholder="{{ localize "password-placeholder" }}">834<button class="btn secondary-btn password-visibility-btn show-password" type="button">{{ localize "show-password" }}</button>835<button class="btn secondary-btn password-visibility-btn hide-password" type="button">{{ localize "hide-password" }}</button>836{{ template "PASSWORD_POLICY" . }}837<button class="btn primary-btn align-self-flex-end" type="submit" name="submit" value="">{{ localize "next-button-label" }}</button>838{{ if eq .x_login_id_input_type "phone" }}839<p class="secondary-txt description">840{{ localize "sms-charge-warning" }}841</p>842{{ end }}843</form>844{{ template "auth_ui_footer.html" . }}845</div>846</body>847</html>848`,849}850var TemplateAuthUISettingsHTML = template.Spec{851 Type: TemplateItemTypeAuthUISettingsHTML,852 IsHTML: true,853 Translation: TemplateItemTypeAuthUITranslationJSON,854 Defines: defines,855 Components: components,856 Default: `<!DOCTYPE html>857<html>858{{ template "auth_ui_html_head.html" . }}859<body class="page">860<div class="content">861{{ template "auth_ui_header.html" . }}862<div class="settings-form primary-txt">863 You are authenticated. To logout, please visit <a href="/logout">here</a>.864</div>865{{ template "auth_ui_footer.html" . }}866</div>867</body>868</html>869`,870}871var TemplateAuthUISettingsIdentityHTML = template.Spec{872 Type: TemplateItemTypeAuthUISettingsIdentityHTML,873 IsHTML: true,874 Translation: TemplateItemTypeAuthUITranslationJSON,875 Defines: defines,876 Components: components,877 Default: `<!DOCTYPE html>878<html>879{{ template "auth_ui_html_head.html" . }}880<body class="page">881<div class="content">882{{ template "auth_ui_header.html" . }}883<div class="settings-identity">884 <h1 class="title primary-txt">{{ localize "settings-identity-title" }}</h1>885 {{ template "ERROR" . }}886 {{ range .x_identity_candidates }}887 <div class="identity">888 <div class="icon {{ .type }} {{ .provider_type }} {{ .login_id_type }}"></div>889 <div class="identity-info flex-child-no-overflow">890 <h2 class="identity-name primary-txt">891 {{ if eq .type "oauth" }}892 {{ if eq .provider_type "google" }}893 {{ localize "settings-identity-oauth-google" }}894 {{ end }}895 {{ if eq .provider_type "apple" }}896 {{ localize "settings-identity-oauth-apple" }}897 {{ end }}898 {{ if eq .provider_type "facebook" }}899 {{ localize "settings-identity-oauth-facebook" }}900 {{ end }}901 {{ if eq .provider_type "linkedin" }}902 {{ localize "settings-identity-oauth-linkedin" }}903 {{ end }}904 {{ if eq .provider_type "azureadv2" }}905 {{ localize "settings-identity-oauth-azureadv2" }}906 {{ end }}907 {{ end }}908 {{ if eq .type "login_id" }}909 {{ if eq .login_id_type "email" }}910 {{ localize "settings-identity-login-id-email" }}911 {{ end }}912 {{ if eq .login_id_type "phone" }}913 {{ localize "settings-identity-login-id-phone" }}914 {{ end }}915 {{ if eq .login_id_type "username" }}916 {{ localize "settings-identity-login-id-username" }}917 {{ end }}918 {{ if eq .login_id_type "raw" }}919 {{ localize "settings-identity-login-id-raw" }}920 {{ end }}921 {{ end }}922 </h2>923 {{ if eq .type "oauth" }}{{ if .email }}924 <h3 class="identity-claim secondary-txt text-ellipsis">925 {{ .email }}926 </h3>927 {{ end }}{{ end }}928 {{ if eq .type "login_id" }}{{ if .login_id_value }}929 <h3 class="identity-claim secondary-txt text-ellipsis">930 {{ .login_id_value }}931 </h3>932 {{ end }}{{ end }}933 </div>934 {{ if eq .type "oauth" }}935 <form method="post" novalidate>936 {{ $.csrfField }}937 <input type="hidden" name="x_idp_id" value="{{ .provider_alias }}">938 {{ if .provider_subject_id }}939 <button class="btn destructive-btn" type="submit" name="x_action" value="unlink">{{ localize "disconnect-button-label" }}</button>940 {{ else }}941 <button class="btn primary-btn" type="submit" name="x_action" value="link" data-form-xhr="false">{{ localize "connect-button-label" }}</button>942 {{ end }}943 </form>944 {{ end }}945 {{ if eq .type "login_id" }}946 <form method="post" novalidate>947 {{ $.csrfField }}948 <input type="hidden" name="x_login_id_key" value="{{ .login_id_key }}">949 <input type="hidden" name="x_login_id_type" value="{{ .login_id_type }}">950 {{ if eq .login_id_type "phone" }}951 <input type="hidden" name="x_login_id_input_type" value="phone">952 {{ else if eq .login_id_type "email" }}953 <input type="hidden" name="x_login_id_input_type" value="email">954 {{ else }}955 <input type="hidden" name="x_login_id_input_type" value="text">956 {{ end }}957 {{ if .login_id_value }}958 <input type="hidden" name="x_old_login_id_value" value="{{ .login_id_value }}">959 <button class="btn secondary-btn" type="submit" name="x_action" value="login_id">{{ localize "change-button-label" }}</a>960 {{ else }}961 <button class="btn primary-btn" type="submit" name="x_action" value="login_id">{{ localize "connect-button-label" }}</a>962 {{ end }}963 </form>964 {{ end }}965 </div>966 {{ end }}967</div>968{{ template "auth_ui_footer.html" . }}969</div>970</body>971</html>972`,973}974var TemplateAuthUILogoutHTML = template.Spec{975 Type: TemplateItemTypeAuthUILogoutHTML,976 IsHTML: true,977 Translation: TemplateItemTypeAuthUITranslationJSON,978 Defines: defines,979 Components: components,980 Default: `<!DOCTYPE html>981<html>982{{ template "auth_ui_html_head.html" . }}983<body class="page">984<div class="content">985{{ template "auth_ui_header.html" . }}986<form class="logout-form" method="post" novalidate>987 {{ $.csrfField }}988 <p class="primary-txt">{{ localize "logout-button-hint" }}</p>989 <button class="btn primary-btn align-self-center" type="submit" name="x_action" value="logout">{{ localize "logout-button-label" }}</button>990</form>991{{ template "auth_ui_footer.html" . }}992</div>993</body>994</html>995`,996}...

Full Screen

Full Screen

print.go

Source:print.go Github

copy

Full Screen

...136 precMul137 precAdd138 precLsh139 precLt140 precEqEq141 precAnd142 precXor143 precOr144 precAndAnd145 precOrOr146 precCond147 precEq148 precComma149 precLow150)151var opPrec = []int{152 Add: precAdd,153 AddEq: precEq,154 Addr: precAddr,155 And: precAnd,156 AndAnd: precAndAnd,157 AndEq: precEq,158 Arrow: precArrow,159 Call: precArrow,160 Cast: precAddr,161 CastInit: precAddr,162 Comma: precComma,163 Cond: precCond,164 Div: precMul,165 DivEq: precEq,166 Dot: precArrow,167 Eq: precEq,168 EqEq: precEqEq,169 Gt: precLt,170 GtEq: precLt,171 Index: precArrow,172 Indir: precAddr,173 Lsh: precLsh,174 LshEq: precEq,175 Lt: precLt,176 LtEq: precLt,177 Minus: precAddr,178 Mod: precMul,179 ModEq: precEq,180 Mul: precMul,181 MulEq: precEq,182 Name: precNone,183 Not: precAddr,184 NotEq: precEqEq,185 Number: precNone,186 Offsetof: precAddr,187 Or: precOr,188 OrEq: precEq,189 OrOr: precOrOr,190 Paren: precLow,191 Plus: precAddr,192 PostDec: precAddr,193 PostInc: precAddr,194 PreDec: precAddr,195 PreInc: precAddr,196 Rsh: precLsh,197 RshEq: precEq,198 SizeofExpr: precAddr,199 SizeofType: precAddr,200 String: precNone,201 Sub: precAdd,202 SubEq: precEq,203 Twid: precAddr,204 VaArg: precAddr,205 Xor: precXor,206 XorEq: precEq,207}208var opStr = []string{209 Add: "+",210 AddEq: "+=",211 Addr: "&",212 And: "&",213 AndAnd: "&&",214 AndEq: "&=",215 Div: "/",216 DivEq: "/=",217 Eq: "=",218 EqEq: "==",219 Gt: ">",220 GtEq: ">=",221 Indir: "*",222 Lsh: "<<",223 LshEq: "<<=",224 Lt: "<",225 LtEq: "<=",226 Minus: "-",227 Mod: "%",228 ModEq: "%=",229 Mul: "*",230 MulEq: "*=",231 Not: "!",232 NotEq: "!=",233 Or: "|",234 OrEq: "|=",235 OrOr: "||",236 Plus: "+",237 PreDec: "--",238 PreInc: "++",239 Rsh: ">>",240 RshEq: ">>=",241 Sub: "-",242 SubEq: "-=",243 Twid: "~",244 Xor: "^",245 XorEq: "^=",246 SizeofExpr: "sizeof ",247}248func (p *Printer) printExpr(x *Expr, prec int) {249 if x == nil {250 return251 }252 if p.html {253 fmt.Fprintf(&p.buf, "<span title='%s type %v'>", x.Op, x.XType)254 defer fmt.Fprintf(&p.buf, "</span>")255 }256 p.Print(x.Comments.Before)257 defer p.Print(x.Comments.Suffix, x.Comments.After)258 var newPrec int259 if 0 <= int(x.Op) && int(x.Op) < len(opPrec) {260 newPrec = opPrec[x.Op]261 }262 if prec < newPrec {263 p.Print("(")264 defer p.Print(")")265 }266 prec = newPrec267 var str string268 if 0 <= int(x.Op) && int(x.Op) < len(opStr) {269 str = opStr[x.Op]270 }271 if str != "" {272 if x.Right != nil {273 // binary operator274 if prec == precEq {275 // right associative276 p.Print(exprPrec{x.Left, prec - 1}, " ", str, " ", exprPrec{x.Right, prec})277 } else {278 // left associative279 p.Print(exprPrec{x.Left, prec}, " ", str, " ", exprPrec{x.Right, prec - 1})280 }281 } else {282 // unary operator283 if (x.Op == Plus || x.Op == Minus || x.Op == Addr) && x.Left.Op == x.Op ||284 x.Op == Plus && x.Left.Op == PreInc ||285 x.Op == Minus && x.Left.Op == PreDec {286 prec-- // force parenthesization +(+x) not ++x287 }288 p.Print(str, exprPrec{x.Left, prec})...

Full Screen

Full Screen

minification_text_test.go

Source:minification_text_test.go Github

copy

Full Screen

...6 "testing"7 "golang.org/x/net/html"8 . "github.com/smartystreets/goconvey/convey"9)10func strEq(name string, t *testing.T, in, out string) {11 Convey(name, t, func() {12 m := minificationText{}13 So(m.processText(in), ShouldEqual, out)14 })15}16func minificationTextCheck(in string, out string) {17 var buf bytes.Buffer18 w := bufio.NewWriter(&buf)19 node, err := html.Parse(bytes.NewReader([]byte(in)))20 if err == nil {21 m := minificationText{}22 So(m.Run(node), ShouldEqual, nil)23 err := html.Render(w, node)24 if err == nil {25 err = w.Flush()26 if err == nil {27 So(string(buf.Bytes()), ShouldEqual, out)28 }29 }30 }31 So(err, ShouldBeNil)32}33func helperTextBody(name string, t *testing.T, in, out string) {34 Convey(name, t, func() {35 fin := fmt.Sprintf("<html><head></head><body>\n%s\n</body></html>", in)36 fout := fmt.Sprintf("<html><head></head><body>%s</body></html>", out)37 minificationTextCheck(fin, fout)38 })39}40// TestMinimizeText ...41func TestMinimizeText(t *testing.T) {42 strEq("Empty string", t,43 "", "")44 strEq("Only spaces", t,45 " ", "")46 strEq("New line, tab and etc.", t,47 " \n\r\t ", "")48 strEq("Without spaces", t,49 "приветworld", "приветworld")50 strEq("One space", t,51 "привет world", "привет world")52 strEq("One new line", t,53 "привет\nworld", "привет world")54 strEq("Left spaces", t,55 " привет world", "привет world")56 strEq("Middle spaces", t,57 "привет world", "привет world")58 strEq("Right spaces", t,59 "привет world ", "привет world")60 strEq("Left, middle and right spaces", t,61 " привет world ", "привет world")62 strEq("Convert separators to space",63 t, "...привет, \t\r\nworld!", "привет world")64 strEq("To lower case",65 t, "ПрИвЕт, WoRlD!", "привет world")66 strEq("Special symbols",67 t, "П&р-и@в_е+т, W'oRlD!", "п&р-и@в_е+т w'orld")68 strEq("Digits",69 t, "привет, 1234567890!", "привет 1234567890")70 strEq("Digits with comma",71 t, "12,5", "12,5")72 strEq("Digits with colon",73 t, "1:6", "1:6")74 strEq("Digits with dot 1",75 t, "123.45", "123.45")76 strEq("Digits with dot 2",77 t, "1230.045", "1230.045")78 strEq("Digits with dot 3",79 t, "1239.945", "1239.945")80 strEq("Dot after digits",81 t, "1239.", "1239")82}83// TestParseErrors ...84func TestParseErrors(t *testing.T) {85 Convey("Test error node type", t, func() {86 in := "<html><head></head><body><!-- Comment1 --></body></html>"87 node, err := html.Parse(bytes.NewReader([]byte(in)))88 So(err, ShouldBeNil)89 m := minificationText{}90 So(m.Run(node).Error(), ShouldEqual, ErrUnexpectedNodeType)91 })92 Convey("Test error node type", t, func() {93 in := "<html><head></head><body><b>123</b></body></html>"94 node, err := html.Parse(bytes.NewReader([]byte(in)))95 So(err, ShouldBeNil)96 m := minificationText{}97 So(m.Run(node).Error(), ShouldEqual, ErrUnexpectedTag)98 })99}100// TestRemoveEmptyTags ...101func TestRemoveEmptyTags(t *testing.T) {102 helperTextBody("Remove empty tag between tags", t,103 "<div>pre</div><div></div><div>post</div>",104 "<div>pre</div><div>post</div>")105 helperTextBody("Remove empty tag between text nodes", t,106 "pre<div></div>post",107 "pre post")108 helperTextBody("Remove empty tag between tag and text node", t,109 "<div>pre</div><div></div>post",110 "<div>pre</div>post")111 helperTextBody("Remove empty tag between text node and tag", t,...

Full Screen

Full Screen

Eq

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "findlinks1: %v/n", err)6 os.Exit(1)7 }8 for _, link := range visit(nil, doc) {9 fmt.Println(link)10 }11}12func visit(links []string, n *html.Node) []string {13 if n.Type == html.ElementNode && n.Data == "a" {14 for _, a := range n.Attr {15 if a.Key == "href" {16 links = append(links, a.Val)17 }18 }19 }20 for c := n.FirstChild; c != nil; c = c.NextSibling {21 links = visit(links, c)22 }23}

Full Screen

Full Screen

Eq

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "findlinks1: %v6 os.Exit(1)7 }8 for _, link := range visit(nil, doc) {9 fmt.Println(link)10 }11}12func visit(links []string, n *html.Node) []string {13 if n.Type == html.ElementNode && n.Data == "a" {14 for _, a := range n.Attr {15 if a.Key == "href" {16 links = append(links, a.Val)17 }18 }19 }20 for c := n.FirstChild; c != nil; c = c.NextSibling {21 links = visit(links, c)22 }23}24import (25func main() {26 doc, err := html.Parse(os.Stdin)27 if err != nil {28 fmt.Fprintf(os.Stderr, "findlinks1: %v29 os.Exit(1)30 }31 for _, link := range visit(nil, doc) {32 fmt.Println(link)33 }34}35func visit(links []string, n *html.Node) []string {36 if n.Type == html.ElementNode && n.Data == "a" {37 for _, a := range n.Attr {38 if a.Key == "href" {39 links = append(links, a.Val)40 }41 }42 }43 for c := n.FirstChild; c != nil; c = c.NextSibling {44 links = visit(links, c)45 }46}47import (48func main() {49 doc, err := html.Parse(os.Stdin)50 if err != nil {51 fmt.Fprintf(os.Stderr, "findlinks1: %v52 os.Exit(1)53 }54 for _, link := range visit(nil, doc) {55 fmt.Println(link)56 }57}58func visit(links []string, n *html.Node) []string {

Full Screen

Full Screen

Eq

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "findlinks1: %v6 os.Exit(1)7 }8 for _, link := range visit(nil, doc) {9 fmt.Println(link)10 }11}12func visit(links []string, n *html.Node) []string {13 if n.Type == html.ElementNode && n.Data == "a" {14 for _, a := range n.Attr {15 if a.Key == "href" {16 links = append(links, a.Val)17 }18 }19 }20 for c := n.FirstChild; c != nil; c = c.NextSibling {21 links = visit(links, c)22 }23}24import (25func main() {26 doc, err := html.Parse(os.Stdin)27 if err != nil {28 fmt.Fprintf(os.Stderr, "findlinks2: %v29 os.Exit(1)30 }31 for _, link := range visit(nil, doc) {32 fmt.Println(link)33 }34}35func visit(links []string, n *html.Node) []string {36 if n.Type == html.ElementNode && n.Data == "a" {37 for _, a := range n.Attr {38 if a.Key == "href" {39 links = append(links, a.Val)40 }41 }42 }43 for c := n.FirstChild; c != nil; c = c.NextSibling {44 links = visit(links, c)45 }46}47import (48func main() {49 doc, err := html.Parse(os.Stdin)50 if err != nil {51 fmt.Fprintf(os.Stderr, "findlinks3: %v52 os.Exit(1)53 }54 for _, link := range visit(nil, doc) {55 fmt.Println(link)56 }57}58func visit(links []string, n *html.Node) []string {

Full Screen

Full Screen

Eq

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "findlinks1: %v6 os.Exit(1)7 }8 for _, link := range visit(nil, doc) {9 fmt.Println(link)10 }11}12func visit(links []string, n *html.Node) []string {13 if n.Type == html.ElementNode && n.Data == "a" {14 for _, a := range n.Attr {15 if a.Key == "href" {16 links = append(links, a.Val)17 }18 }19 }20 for c := n.FirstChild; c != nil; c = c.NextSibling {21 links = visit(links, c)22 }23}24import (25func main() {26 doc, err := html.Parse(os.Stdin)27 if err != nil {28 fmt.Fprintf(os.Stderr, "findlinks1: %v29 os.Exit(1)30 }31 for _, link := range visit(nil, doc) {32 fmt.Println(link)33 }34}35func visit(links []string, n *html.Node) []string {36 if n.Type == html.ElementNode && n.Data == "a" {37 for _, a := range n.Attr {38 if a.Key == "href" {39 links = append(links, a.Val)40 }41 }42 }43 for c := n.FirstChild; c != nil; c = c.NextSibling {44 links = visit(links, c)45 }46}47import (48func main() {49 doc, err := html.Parse(os.Stdin)50 if err != nil {51 fmt.Fprintf(os.Stderr, "findlinks1: %v52 os.Exit(1)53 }54 for _, link := range visit(nil, doc) {55 fmt.Println(link)56 }57}58func visit(links []string, n *html.Node) []string {

Full Screen

Full Screen

Eq

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(strings.NewReader("<html><body><h1>Hello</h1></body></html>"))4 if err != nil {5 log.Fatal(err)6 }

Full Screen

Full Screen

Eq

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, _ := html.Parse(strings.NewReader("<html><head><title>Test</title></head><body></body></html>"))4 fmt.Println(doc.FirstChild.FirstChild.FirstChild.Data)5}6import (7func main() {8 doc, _ := html.Parse(strings.NewReader("<html><head><title>Test</title></head><body></body></html>"))9 fmt.Println(doc.FirstChild.FirstChild.FirstChild.Data)10}11import (12func main() {13 doc, _ := html.Parse(strings.NewReader("<html><head><title>Test</title></head><body></body></html>"))14 fmt.Println(doc.FirstChild.FirstChild.FirstChild.Data)15}16import (17func main() {18 doc, _ := html.Parse(strings.NewReader("<html><head><title>Test</title></head><body></body></html>"))19 fmt.Println(doc.FirstChild.FirstChild.FirstChild.Data)20}21import (22func main() {23 doc, _ := html.Parse(strings.NewReader("<html><head><title>Test</title></head><body></body></html>"))24 fmt.Println(doc.FirstChild.FirstChild.FirstChild.Data)25}26import (27func main() {28 doc, _ := html.Parse(strings.NewReader("<html><head><title>Test</title></head><body></body></html>"))29 fmt.Println(doc.FirstChild.FirstChild.FirstChild.Data)30}31import (32func main() {33 doc, _ := html.Parse(strings.NewReader("<

Full Screen

Full Screen

Eq

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc1, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "findlinks1: %v6 os.Exit(1)7 }8 doc2, err := html.Parse(os.Stdin)9 if err != nil {10 fmt.Fprintf(os.Stderr, "findlinks1: %v11 os.Exit(1)12 }13 if html.Eq(doc1, doc2) {14 fmt.Println("The two nodes are equal")15 } else {16 fmt.Println("The two nodes are not equal")17 }18}

Full Screen

Full Screen

Eq

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 n := &html.Node{4 }5 fmt.Println(n.Eq(&html.Node{6 }))7}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful