% '======================================================================================================================= ' HTML HELPER '======================================================================================================================= Class HTML_Helper_Class 'Duplicate of Routes.NoCacheToken, copied to avoid extra lookup into the Routes object for such a trivial function. 'Allows caller to reference HTML.NoCacheToken in cases where it seems to feel right. Public Property Get NoCacheToken NoCacheToken = Timer() * 100 End Property 'Ensures safe output Public Function Encode(ByVal value) If Not IsEmpty(value) and Not IsNull(value) then Encode = Server.HtmlEncode(value) End If End Function '--------------------------------------------------------------------------------------------------------------------- 'LinkTo and its relatives DO NOT HTMLEncode the link_text! This allows use of HTML within the link, especially 'useful for Bootstrap icons and the like. ' 'Bottom Line: If you need to HTMLEncode the link text YOU MUST DO IT YOURSELF! The H() method makes this easy! Public Function LinkTo(link_text, controller_name, action_name) LinkTo = LinkToExt(link_text, controller_name, action_name, empty, empty) End Function Public Function LinkToExt(link_text, controller_name, action_name, params_array, attribs_array) LinkToExt = "" & link_text & "" & vbCR End Function Public Function LinkToIf(condition, link_text, controller_name, action_name) if condition then LinkToIf = LinkToExt(link_text, controller_name, action_name, empty, empty) end if End Function Public Function LinkToExtIf(condition, link_text, controller_name, action_name, params_array, attribs_array) if condition then LinkToExtIf = LinkToExt(link_text, controller_name, action_name, params_array, attribs_array) end if End Function Public Function LinkToUnless(condition, link_text, controller_name, action_name) if not condition then LinkToIf = LinkToExt(link_text, controller_name, action_name, empty, empty) end if End Function Public Function LinkToExtUnless(condition, link_text, controller_name, action_name, params_array, attribs_array) if not condition then LinkToExtUnless = LinkToExt(link_text, controller_name, action_name, params_array, attribs_array) end if End Function '' ' Creates a form button and a hidden form to enforce POST submissions. Params are in hidden fields. '' 'Public Function PostButtonLinkTo(controller_name, action_name, params) ' dim id : id = "post_button__" & controller_name & action_name ' dim s ' s = "
" ' PostButtonLinkTo = s 'End Function Public Function PostButtonTo(button_contents, controller_name, action_name, form_fields) PostButtonTo = PostButtonToExt(button_contents, controller_name, action_name, form_fields, empty) End Function Public Function PostButtonToExt(button_contents, controller_name, action_name, form_fields, url_params) dim s : s = "" & vbCR PostButtonToExt = s End Function Public Function AppStylesheetTag AppStylesheetTag = StylesheetTag(Routes.StylesheetsURL & "App.css") End Function Public Function ControllerStylesheetTag ControllerStylesheetTag = StylesheetTag(Routes.StylesheetsUrl & MVC.ControllerName & "Controller.css") End Function Public Function StylesheetTag(url) StylesheetTag = "" & vbCR End Function Public Function JSTag(url) JSTag = "" & vbCR End Function '--------------------------------------------------------------------------------------------------------------------- ' Form Helpers '--------------------------------------------------------------------------------------------------------------------- Public Function FormTag(controller_name, action_name, route_attribs, form_attribs) FormTag = "