5

The "Component Template Metadata" that's part of DXA has this field: HTML class(es) (if multiple, separate by a space). How do I reference that on a view? I have two blocks of content that are structured very similarly & that would be a perfect way to only use one view. Each unique style can have its own class in the CT.

Can that be added to the model semantics so that it comes thru that way?

1 Answer 1

6

That piece of metadata is automatically mapped to the HtmlClasses property of the View Model (each View Model inherits that property from class ViewModel). View code can include it in the HTML using Model.HtmlClasses (see, for example, the Core Views).

This facility indeed allows you to have diffently styled views based on the same view code.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.