<tfoot id='rHp51'></tfoot>
      <bdo id='rHp51'></bdo><ul id='rHp51'></ul>

  1. <small id='rHp51'></small><noframes id='rHp51'>

    <i id='rHp51'><tr id='rHp51'><dt id='rHp51'><q id='rHp51'><span id='rHp51'><b id='rHp51'><form id='rHp51'><ins id='rHp51'></ins><ul id='rHp51'></ul><sub id='rHp51'></sub></form><legend id='rHp51'></legend><bdo id='rHp51'><pre id='rHp51'><center id='rHp51'></center></pre></bdo></b><th id='rHp51'></th></span></q></dt></tr></i><div id='rHp51'><tfoot id='rHp51'></tfoot><dl id='rHp51'><fieldset id='rHp51'></fieldset></dl></div>

      <legend id='rHp51'><style id='rHp51'><dir id='rHp51'><q id='rHp51'></q></dir></style></legend>

      如何以更好的方式从 ASP 编辑 html?

      时间:2023-10-13
    1. <tfoot id='KPYRq'></tfoot>

      1. <i id='KPYRq'><tr id='KPYRq'><dt id='KPYRq'><q id='KPYRq'><span id='KPYRq'><b id='KPYRq'><form id='KPYRq'><ins id='KPYRq'></ins><ul id='KPYRq'></ul><sub id='KPYRq'></sub></form><legend id='KPYRq'></legend><bdo id='KPYRq'><pre id='KPYRq'><center id='KPYRq'></center></pre></bdo></b><th id='KPYRq'></th></span></q></dt></tr></i><div id='KPYRq'><tfoot id='KPYRq'></tfoot><dl id='KPYRq'><fieldset id='KPYRq'></fieldset></dl></div>

        <small id='KPYRq'></small><noframes id='KPYRq'>

          <tbody id='KPYRq'></tbody>
              <legend id='KPYRq'><style id='KPYRq'><dir id='KPYRq'><q id='KPYRq'></q></dir></style></legend>
                <bdo id='KPYRq'></bdo><ul id='KPYRq'></ul>
                本文介绍了如何以更好的方式从 ASP 编辑 html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                您好,我有一个需要编辑的 ASP 脚本.实际上我需要重新设置它发送的电子邮件的样式,所以我需要从中编辑 HTML.

                Hello I have an ASP script that I need to edit. Actually I need to restyle the email that it sends, so I need to edit the HTML from it.

                问题是html(来自asp文件)在每一行都有

                The problem is the html (from the asp file) has on every row

                HTML = HTML & =" 
                

                在其中(加上其他一些更改).我需要从该 ASP 中获取 HTML 代码,去掉开头的 html = html 部分,编辑双 "" 并将它们转换为单个 " (我需要一一做,因为变量中也有引号).

                in it (plus some other changes). I need to take the HTML code from that ASP, get rid of the beginning html = html part, edit the double "" and convert them to a single " (I need to do that one by one, because the variables also have quotes in them).

                然后,我用 HTML 重新设置页面的样式,然后我需要将它转换回来,以便我可以将它集成到 ASP (基本上再次引入双 '"' 和其他东西).

                Than, I restyle the page with HTML and after that I need to convert it back so I can integrate it in ASP (basically introduce the double '"' again and stuff).

                是的,我可以直接从 ASP 编辑 HTML,但我不知道它的外观,因为我无法运行脚本 (它需要来自服务器的其他文件,我不需要't 有权访问).

                Yeah, I could edit the HTML from the ASP directly, but I don't know how it might look, because I can't run the script (it needs other files from the server, which I don't have access to).

                问题:

                有更好的方法吗?

                某种方式可以直接预览我在 ASP 中所做的事情.或者也许是一个工具,可以让我从 ASP HTML 移动到 HTML 并更快地返回.

                Some way of previewing what I'm doing in ASP directly. Or maybe a tool that let's me move from ASP HTML to HTML and back faster.

                我当然知道我现在做的很蠢,所以一定有更好的办法.

                I sure know that what I'm doing right now is quite dumb, so there must be a better way.

                推荐答案

                作为 @steve-holland 提及创建模板是避免代码中所有烦人的 HTML 字符串并使更改布局变得轻而易举的好方法.

                As @steve-holland mentions creating a template is a great way to avoid all the annoying HTML strings in the code and makes changing layouts a breeze.

                我过去曾自己处理过 HTML 模板脚本,通常我会构建一个 Scripting.Dictionary,其中包含我将在模板中替换的键值对.

                I've worked on HTML templating scripts myself in the past, usually I build a Scripting.Dictionary that contains the key value pairs I will be replacing inside the template.

                Function getHTMLTemplate(url, params)
                  Dim stream, keys, html, idx
                
                  Set stream = Server.CreateObject("ADODB.Stream")
                  With stream
                    .Type = adTypeText
                    .Charset = "utf-8"
                    Call .Open()
                    Call .LoadFromFile(url)
                    html = .ReadText(adReadAll)
                    Call .Close()
                  End With
                  Set stream = Nothing
                
                  keys = o_params.Keys
                  For idx = 0 To UBound(keys, 1)
                    html = Replace(html, keys(idx), params.Item(keys(idx)))
                  Next
                  Set keys = Nothing
                  Set params = Nothing
                
                  getHTMLTemplate = html
                End Function
                

                用法:

                Dim params, html
                Set params = Server.CreateObject("Scripting.Dictionary")
                With params
                  .Add("[html_title]", "Title Here")
                  .Add("[html_logo]", "/images/logo.gif")
                  '... and so on
                End With
                
                html = getHTMLTemplate(Server.MapPath("/templates/main.htm"), params)
                
                Call Response.Write(html)
                

                示例main.htm结构:

                <!doctype html>
                <html>
                  <head>
                    <title>[html_title]</title>
                    <link rel="stylesheet" type="text/css" href="/styles/main.css" />
                  </head>
                
                  <body>
                    <div class="header">
                      <img src="[html_logo]" alt="Company Name" />
                    </div>
                  </body>
                </html>
                

                为什么使用 ADODB.Stream 而不是 Scripting.FileSystemObject?;

                Why use a ADODB.Stream instead of the Scripting.FileSystemObject?;

                1. 您可以控制返回的 Charset,如果需要,甚至可以从一个字符集转换为另一个字符集.

                1. You can control the Charset being returned and even convert from one to another if you need to.

                如果模板特别大,您可以使用 Read() 方法以特定的缓冲区大小将内容流式传输,以提高读取的性能.

                If the template is particular large, you can stream the content in using the Read() method with a specific buffer size to improve the performance of the read.

                这篇关于如何以更好的方式从 ASP 编辑 html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:打开一个新窗口创建一个新会话 下一篇:查明 JS-ASP 中是否存在 URL 参数

                相关文章

                最新文章

                <legend id='1Neba'><style id='1Neba'><dir id='1Neba'><q id='1Neba'></q></dir></style></legend>

                  1. <i id='1Neba'><tr id='1Neba'><dt id='1Neba'><q id='1Neba'><span id='1Neba'><b id='1Neba'><form id='1Neba'><ins id='1Neba'></ins><ul id='1Neba'></ul><sub id='1Neba'></sub></form><legend id='1Neba'></legend><bdo id='1Neba'><pre id='1Neba'><center id='1Neba'></center></pre></bdo></b><th id='1Neba'></th></span></q></dt></tr></i><div id='1Neba'><tfoot id='1Neba'></tfoot><dl id='1Neba'><fieldset id='1Neba'></fieldset></dl></div>
                      <bdo id='1Neba'></bdo><ul id='1Neba'></ul>

                    <small id='1Neba'></small><noframes id='1Neba'>

                  2. <tfoot id='1Neba'></tfoot>