grass/src/atrule/mixin.rs

45 lines
1.1 KiB
Rust
Raw Normal View History

2020-07-08 17:52:37 -04:00
use crate::{args::FuncArgs, Token};
2020-01-12 20:15:40 -05:00
#[derive(Debug, Clone)]
pub(crate) struct Mixin {
2020-06-16 19:38:30 -04:00
pub args: FuncArgs,
2020-06-30 06:53:17 -04:00
pub body: Vec<Token>,
2020-06-16 19:38:30 -04:00
pub accepts_content_block: bool,
2020-07-08 14:51:04 -04:00
pub declared_at_root: bool,
2020-01-12 20:15:40 -05:00
}
impl Mixin {
2020-06-16 19:38:30 -04:00
pub fn new(
args: FuncArgs,
body: Vec<Token>,
accepts_content_block: bool,
2020-07-08 14:51:04 -04:00
declared_at_root: bool,
2020-06-16 19:38:30 -04:00
) -> Self {
Mixin {
args,
body,
accepts_content_block,
2020-07-08 14:51:04 -04:00
declared_at_root,
2020-01-12 20:15:40 -05:00
}
}
}
2020-07-02 10:31:32 -04:00
2020-07-02 15:22:15 -04:00
#[derive(Debug, Clone)]
2020-07-02 10:31:32 -04:00
pub(crate) struct Content {
/// The literal block, serialized as a list of tokens
2020-07-02 10:31:32 -04:00
pub content: Option<Vec<Token>>,
/// Optional args, e.g. `@content(a, b, c);`
2020-07-02 10:31:32 -04:00
pub content_args: Option<FuncArgs>,
/// The number of scopes at the use of `@include`
///
/// This is used to "reset" back to the state of the `@include`
/// without actually cloning the scope or putting it in an `Rc`
pub scope_len: usize,
/// Whether or not the mixin this `@content` block is inside of was
/// declared in the global scope
pub declared_at_root: bool,
2020-07-02 10:31:32 -04:00
}