Skip to content

Expression support for text content #7

@mysticfall

Description

@mysticfall

We should be able to use expressions inside a component's markup, as well as any dynamic contents it might generate during the initialization:

@name("sc-profile")
trait ProfileComponent extends Component[Div] {
  @JSExport
  var user: User
}
<sc-users var="user">
  <sc-profile user="%{user}">
    User : %{user.name} (%{user.email})
  </sc-profile>
</sc-users>

Or, if a template is used to create the content:

@name("sc-profile")
trait ProfileComponent extends Component[Div] 
  with TemplateContentProvider[Div] {

  @JSExport
  var user: User

  override def templateSelector = "#profile"
}
<template id="profile">
  User : %{user.name} (%{user.email})
</template>

<sc-users var="user">
  <sc-profile user="%{user}" />
</sc-users>

Note that the component should not try to evaluate expression nodes, if they are not immediate children of the component:

<sc-parent>
  %{value1} <!-- handled by sc-parent -->
  <sc-child>
    %{value2} <!-- handled by sc-child -->
  </sc-child>
</sc-parent>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions