use crate::prelude::*;
use beet_core::prelude::*;
pub trait TemplateDirective: 'static + Sized + Component {
fn try_from_attribute(key: &str, value: Option<&TextNode>) -> Option<Self>;
}
pub fn try_extract_directive<T: TemplateDirective>(
mut commands: Commands,
query: Populated<(Entity, &AttributeOf, &AttributeKey, Option<&TextNode>)>,
) {
for (entity, parent, key, value) in query.iter() {
if let Some(directive) = T::try_from_attribute(key, value) {
commands.entity(**parent).insert(directive);
commands.entity(entity).despawn();
}
}
}