우리는 Aurelia 앱에서 데이터를 렌더링하기 위해 API를 사용하여 WordPress에 모든 페이지 콘텐츠와 블로그 게시물 등을 저장합니다. 이것은 잘 작동하고 있습니다.Aurelia로 동적으로 HTML을 향상시키는 방법
<div class="excerpt" innerhtml.bind="post.excerpt.rendered"></div>
저자는 지금 팝업에 링크하거나 route-href
또는 아우렐 리아는 자신의 블로그 게시물 내에서 속성을 다른 사용자 지정을 사용할 수 있도록하고 싶습니다 그러나 코드는 innerhtml.bind
가 아우렐 리아에 의해 해석되지 않습니다 사용하여 페이지에 추가.
은 내가이 아우렐 리아에서 <a href="...">
"바로 작동"정상적인 것을 좋아한다 -.? 그러나 우리는 저자가 사용할 수없는 사용자 지정 특성 (같은 <button popup="name-of-popup">...</button>
의 많음이 우리가 이것을 극복 할 수있는 방법
편집 : @bigopon의 의견을 통해 뭔가 시작했지만 아직 제대로 작동하지 않습니다. 검색시 빨거나 문서가 약간 부족한 TemplatingEngine.enhance()
메서드가 있지만 시도해 보았습니다. 다음과 같은 맞춤 속성 :
import {Aurelia, inject, TemplatingEngine} from 'aurelia-framework';
@inject(Element, Aurelia, TemplatingEngine)
export class AureliaEnhanceCustomAttribute {
constructor (el, aurelia, templatingEngine) {
this.el = el;
this.aurelia = aurelia; // NOTE: I've never done this before - is it even correct?
this.templatingEngine = templatingEngine;
}
attached() {
this.el.innerHTML = this.value;
// NOTE: Without checking for this we get an endless loop of attached() calls
if (!this.el.classList.contains('au-target')) {
this.templatingEngine.enhance({
element: this.el,
container: Aurelia.container, // NOTE: I'm guessing here
resources: Aurelia.resources, // NOTE: Same here, but I need all my global resources to be available inside the enhanced element too
bindingContext: {} // NOTE: Not sure what to pass in here at all.. :/
});
}
}
}
그리고 내가 그렇게처럼 사용하고 있습니다 :
exampleContent
이 같은 것을 볼 수있는 API 호출에서 가져온 문자열입니다
<div aurelia-enhance.bind="exampleContent"></div>
: '<my-custom-element></my-custom-element><button my-custom-attribute="some-value">Log in</button>'
합니다.
당신이 innerHTML을 사용시, "구문 분석"에 의해 무엇을 의미합니까? – bigopon
글쓴이가 블로그 게시물이나 페이지에서 맞춤 속성이나 요소를 사용하면 Aurelia에서 "구문 분석하지 않았습니다 (아마도 잘못된 단어일까요?). 요소 나 속성이 실행되지 않습니다. – powerbuoy
당신이 필요로하는 것은'innerhtml'이 아니며,'TemplatingEngine''compose' /'enhance' 함수를 사용하면 도움이 될 것입니다. – bigopon