0
express에서보기 엔진으로 express-handlebars을 사용하고 handlebars helpers을 사용합니다. 어디 내가 선택한 태그에 대한 작은 부분을 만들었지 만 문자열로 일반 키를 rening.핸들 바 부분에서 오브젝트 키를 구문 분석하는 방법.
에서 객체의 배열을 전달내 선택 파셜 select.hbs 파일
<select name="" id="">
<option value="">Select</option>
{{#forEach this.select_values}}
<option value="{{../this.opt_value}}"> {{ ../this.opt_label }} </option>
{{/forEach}}
</select>
내가 울부 짖는 사용하고
{{> modules/select select_values=accounts opt_value='name' opt_label='email'}}
레이아웃
accounts: [
{
name: 'John',
email: '[email protected]'
},
{
name: 'Malcolm',
email: '[email protected]'
},
{
name: 'David',
email: '[email protected]'
}
]
호출 파셜 계정그것은 핸들 작동
"dependencies": {
"body-parser": "~1.18.2",
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.15.5",
"express-handlebars": "^3.0.0",
"handlebars-helpers": "^0.10.0",
"hbs": "^4.0.1",
"morgan": "~1.9.0",
"serve-favicon": "~2.4.5"
}
예제의 코드는 룩업 도우미를 사용하지 않습니다. – 76484
잘못된 붙여 넣은 이전 코드 정확함 감사합니다. – PratapRockerss