score:0

Accepted answer

You could use repeated (String, String) tuples as the last parameter:

@(fieldId: String, fieldTitle: String, data: (String, String) *)

<div class="form-group">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <label for="@fieldId" class="control-label">@fieldTitle</label>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <span class="input-icon input-icon-right" style="width:100%">
        <input type="text" class="autocomplete-relation" 
        name="@fieldId" 
        data-id-status="@fieldTitle" 
        @data.map{ case (key, value) => 
            @{key}="@{value}"
        }
        style="width:100%"
        />
        <i id="response_@fieldTitle" class="icon-search blue"></i>
    </span>
    </div>
</div>

And you'd call it the way you're wanting:

@autocomplete("someId", "someTitle", "data-url" -> "google.com", "data-attr" -> "someValue")

You could also use a Map[String, String].

@(fieldId: String, fieldTitle: String, data: Map[String, String])

The rest of the template would remain the same, but you'd pass it something like this:

Map[String, String](
    "data-url" -> "google.com",
    "data-field-something" -> "value"
)

Related Query

More Query from same tag