Add String_with_vars.text_only

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
Jeremie Dimino 2018-06-30 00:04:26 +01:00 committed by Jérémie Dimino
parent b4dd6565b2
commit 79f3506922
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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