首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Umbraco 8宏Back Office中未呈现的某些HTML标记

Umbraco 8宏Back Office中未呈现的某些HTML标记
EN

Stack Overflow用户
提问于 2019-11-08 15:09:30
回答 1查看 278关注 0票数 0

我正在将一个项目从Umbraco 7升级到8。我注意到在8中,只有特定的html标签会从宏html文件中呈现出来。例如,如果我在我的宏局部视图中使用以下html:

代码语言:javascript
复制
<div>
    <button>send</button>
    <input type='text' placeholder='some field' style='border: solid 1px #000' />
    <a href="https://www.google.com">some link</a>
</div>

在后台,DOM中的html呈现如下:

A标记和div呈现得很好,但是按钮和输入被剥离了。我已经尝试过使用HTML.Raw,但都没有用。

当我发布内容时,它呈现得很好:-

有没有人在Umbraco 8中遇到过这个问题?

EN

回答 1

Stack Overflow用户

发布于 2019-11-13 15:19:00

事实证明,Umbraco/lib/angular-sanitize/angular-sanitize.js文件正在剥离HTML标记和属性。

有一组白名单变量,你可以添加你的html标签和属性到其中--后台将会渲染它们。

代码语言:javascript
复制
    // Safe Block Elements - HTML5
      var blockElements = extend({}, optionalEndTagBlockElements, stringToMap('address,article,' +
              'aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,' +
              'h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,section,table,ul,form')); //SG: added form

      // Inline Elements - HTML5
      var inlineElements = extend({}, optionalEndTagInlineElements, stringToMap('a,abbr,acronym,b,' +
              'bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,' +
            'samp,small,span,strike,strong,sub,sup,time,tt,u,var,input,button')); //SG: added input, button

  // Blocked Elements (will be stripped)
  var blockedElements = stringToMap('script'); //SG: Removed ,style

  var htmlAttrs = stringToMap('abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,' +
      'color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,' +
      'ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,' +
      'scope,scrolling,shape,size,span,start,summary,tabindex,target,title,type,' +
        'valign,value,vspace,width,action,method,autocomplete,enctype,style'); //SG: Added action,method,autocomplete,enctype,style

你可以在这里阅读更多关于这个umbraco 8‘功能’的信息- https://www.stephengarside.co.uk/blog/webdev/umbraco-8-removing-html-tags-and-attributes-from-macros-in-back-office/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58761981

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档