Text Templates in Standard ML

(* Standard ML offers built-in support for string manipulation and 
   output. We'll use the TextIO structure for printing to the console. *)

(* We can create a new string template and use string concatenation 
   to insert values dynamically. *)

fun createTemplate value = "Value is " ^ value ^ "\n"

(* By applying the template function, we generate its text with
   specific values. *)

val _ = TextIO.print (createTemplate "some text")
val _ = TextIO.print (createTemplate (Int.toString 5))
val _ = TextIO.print (createTemplate (String.concatWith ", " ["SML", "OCaml", "F#", "Haskell"]))

(* If the data is a record (similar to a struct), we can use pattern matching
   to access its fields. *)

fun nameTemplate {name} = "Name: " ^ name ^ "\n"

val _ = TextIO.print (nameTemplate {name = "Jane Doe"})

(* For maps, we can use the built-in operations of the polymorphic map structure. *)

structure StringMap = BinaryMapFn(struct
  type ord_key = string
  val compare = String.compare
end)

val personMap = StringMap.insert(StringMap.empty, "Name", "Mickey Mouse")
val _ = TextIO.print ("Name: " ^ (StringMap.find(personMap, "Name") |> valOf) ^ "\n")

(* Conditional execution in Standard ML is typically done with pattern matching
   or if-then-else expressions. *)

fun conditionalTemplate value =
    if value <> "" then "yes\n" else "no\n"

val _ = TextIO.print (conditionalTemplate "not empty")
val _ = TextIO.print (conditionalTemplate "")

(* List iteration in Standard ML can be done with recursive functions
   or higher-order functions like map or foldl. *)

fun rangeTemplate lst =
    "Range: " ^ (String.concatWith " " lst) ^ "\n"

val _ = TextIO.print (rangeTemplate ["SML", "OCaml", "F#", "Haskell"])

This Standard ML code demonstrates similar concepts to the original Go example, including string manipulation, record access, map operations, conditional execution, and list iteration. Note that Standard ML uses different syntax and idioms, such as pattern matching and higher-order functions, which are more idiomatic in functional programming languages.

To run this program, you would typically save it as a .sml file and use an Standard ML interpreter or compiler, such as MLton or Poly/ML. The exact command may vary depending on your Standard ML implementation, but it might look something like this:

$ mlton template_example.sml
$ ./template_example

Or for interactive use:

$ sml template_example.sml

The output would be similar to the original Go example, demonstrating various string manipulations and template-like operations in Standard ML.