Skip to main content

oak_django/language/
mod.rs

1use crate::ast::DjangoRoot;
2use oak_core::{Language, LanguageCategory};
3use serde::{Deserialize, Serialize};
4
5/// Django 模板语言配置
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct DjangoLanguage {
8    /// 是否启用严格模式
9    pub strict_mode: bool,
10    /// 是否允许自定义标签
11    pub allow_custom_tags: bool,
12}
13
14impl DjangoLanguage {
15    /// 创建新的 Django 语言实例
16    pub fn new() -> Self {
17        Self::default()
18    }
19}
20
21impl Default for DjangoLanguage {
22    fn default() -> Self {
23        Self { strict_mode: false, allow_custom_tags: true }
24    }
25}
26
27impl Language for DjangoLanguage {
28    const NAME: &'static str = "django";
29    const CATEGORY: LanguageCategory = LanguageCategory::Programming;
30
31    type TokenType = crate::kind::DjangoSyntaxKind;
32    type ElementType = crate::kind::DjangoSyntaxKind;
33    type TypedRoot = DjangoRoot;
34}