diff --git a/src/string_with_vars.ml b/src/string_with_vars.ml index 60f35ffa..ed481966 100644 --- a/src/string_with_vars.ml +++ b/src/string_with_vars.ml @@ -272,3 +272,8 @@ let is_var { template; syntax_version = _ } ~name = match template.parts with | [Var n] -> name = Var.full_name n | _ -> false + +let text_only t = + match t.template.parts with + | [Text s] -> Some s + | _ -> None diff --git a/src/string_with_vars.mli b/src/string_with_vars.mli index 72642ce9..bbc080ee 100644 --- a/src/string_with_vars.mli +++ b/src/string_with_vars.mli @@ -30,6 +30,9 @@ val virt_text : (string * int * int * int) -> string -> t val is_var : t -> name:string -> bool +(** If [t] contains no variable, returns the contents of [t]. *) +val text_only : t -> string option + module Mode : sig type 'a t = | Single : Value.t t