Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

FC035 - Templates, Style #62

Closed
miketheman opened this issue Aug 29, 2012 · 2 comments
Closed

FC035 - Templates, Style #62

miketheman opened this issue Aug 29, 2012 · 2 comments

Comments

@miketheman
Copy link
Contributor

As discussed in #60, the FC035 rule needs some RFC discussion.

There is some reasoning behind not including computations in a template file, and other reasons for including node attributes in the template file.

An example of how a node's attribute could be mutated between the time a template resource declaration and the rendering of said resource is here. This is somewhat a contrived example, and doing this is itself probably an anti-pattern to be mindful of.

This issue is to discuss what should probably be in FC035's logic.

@acrmp
Copy link
Member

acrmp commented Aug 29, 2012

Hi Mike,

Thanks for kicking this off.

  • Passing in a subset (node['ntp']) is more explicit for complex / long templates because you can see more easily what is being accessed. We could check to see if all your attribute usage in the template (ignoring hostname etc) is under a common attribute parent and recommend this. This makes more sense the deeper the level of attribute nesting.
  • If the template only uses a couple of node attributes then passing them individually as variables is a bit more explicit but probably not worth warning for.

Cheers,

Andrew.

@miketheman
Copy link
Contributor Author

It's been a few years, and I think we've settled into a good enough pattern on when to use node attributes directly in a template vs when not to. Closing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants