2-3 Expression Language
Using Expression Language

playground.restaurant์์ ์ฌ์ฉ๋ Expression Language์ ๋ํด ์์๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค. ์ค๋ช ์ ๋ฐ๋ผ๊ฐ๋ฉด์ ์ ์ฝ๋์ ๋น์์ ธ ์๋ value์ template ๋ถ๋ถ์ ์ฑ์๋ณด์ธ์.

์์ Restaurant ๊ตฌ์กฐ์ฒด์๋ ์์์ ์ ์ด๋ฆ์ธ name, ์ฃผ์์ธ location ๊ทธ๋ฆฌ๊ณ ์ด๋ฏธ์ง์ ์ฃผ์์ธ url์ด ๋ด๊ฒจ์ ธ ์์ต๋๋ค.
์ง๊ธ๋ถํฐ Developer Center์ ์์ ๋ฅผ ํตํด์ ์ ๋ต์ ์ฐพ์๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค!
Bixby์ Expression Language(EL)๋ ์ฌ์ฉ์๊ฐ ์บก์์ concept, action, layout ๊ทธ๋ฆฌ๊ณ dialog๋ฅผ ๋ง๋ค ์ ์๋๋ก ๋์์ฃผ๋ ๊ธฐ๋ฅ์ ์ํํฉ๋๋ค.
Expression Language๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์๋์ ๊ฐ์ต๋๋ค. (layout ์ด์ธ์ concept, action ๊ทธ๋ฆฌ๊ณ dialog ํ์ผ ๋ฑ์์๋ Expression Language๋ฅผ ์ฌ์ฉํ์ค ์ ์์ต๋๋ค.)
layout {
mode (Summary)
match: Recipe (this)
content {
section {
title {
template ("#{value(this.name)}")
}
content {
if (exists(this.totalTime)) {
single-line {
text {
value ("Total Time: #{value(this.totalTime)} minutes")
}
}
}
if (exists(recipe.servings)) {
single-line {
text {
value ("Servings: #{value(servings)}")
}
}
}
}
}
}
}
์ ์ฝ๋๋ฅผ ์ดํด๋ณด๋ฉด match๋ Recipe์ ๊ฐ์ (this) ๋ณ์์ ๋ฐ์ธ๋ฉํ๊ณ ์์ต๋๋ค.
this
์ฌ๋กฏ์.
operator๋ฅผ ์ฌ์ฉํ์ฌ ์ ๊ทผ์ด ๊ฐ๋ฅํฉ๋๋ค. (ex)this.name
exists(this.totalTime)
ํจ์๋ this.totalTime์ ๊ฐ์ด ์๋์ง ํ์ธํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ๋ง์ฝ match ํจํด์ด Recipe(this)๊ฐ ์๋๋ผ Recipe (r)์ด์๋ค๋ฉด,exists(r.totalTime)
๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค.Expression Language๋
#{}
ํํ์ผ๋ก ์ฌ์ฉ๋ ์ ์์ต๋๋ค. ๋ฐ๋ผ์,#{value(this.totalTime)}
๋ this.totalTime์ ๊ฐ์ ๋ฐํํ๋ ํํ์ผ๋ก ์ฌ์ฉ๋ฉ๋๋ค.
Last updated
Was this helpful?