Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Docs: Multiple definitions for 'template'. #8063

Closed
@Izhaki

Description

@Izhaki

In the Templates docs

In Angular, templates are written with HTML that contains Angular-specific elements and attributes.

OK, so essentially this are HTML snippets, with some custom markup.

In the directive definition object

replace the current element with the contents of the HTML. The replacement process migrates all of the attributes / classes from the old element to the new one. See the Directives Guide for an example.

Per #8062, this definition is ill to the bone. It should probably say:

Replaces the contents of the element on which the directive is declared with the markup provided in the template property.

But that's now the second template definition, that somehow still works with the first one.

But if the following is a template:

<my-directive></my-directive>

Than the directive template is essentially a template to replace parts of the template above.

Wouldn't changing the template property to contents be better?

In Compile API

Compiles an HTML string or DOM into a template.

Ok, isn't, given the first definition, the HTML string (I guess that's the directive's template) and the DOM are already templates? In other words - for something to be compiled, it must be a template in the first place.

This definition contradicts the first definition, and I can't see way out of this given the first definition.

tElement - template element - The element where the directive has been declared. It is safe to do template transformation on the element and child elements only.

I guess it is titled template element since it has Angular markup, thus it is a template. But given the second definition, this is somewhat confusing.

It then goes on to say:

template instance and the link instance may be different objects if the template has been cloned.

I guess by 'template instance' the meaning is the (pre-linked, or 'complied') template 'blueprint', which may be cloned; and the 'link instance' the meaning is 'the post-linked (rendered) markup'.

The 'if the template has been cloned' makes sense with the first definition

Summary

It seems there are at least 3 definitions for template:

  • An HTML that has Angular markup.
  • A contents replacement markup in a directive.
  • Something that is produced when Angular compiles HTML or DOM

@caitp

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions