我正在处理涉及API的第一个项目。
我正在使用的API为我提供了以下字符串:
"In our nation’s capital, killings have risen by 50 percent."
有没有办法可以简单地将代码转换为字符?或者我是否需要一遍又一遍地呼叫gsub
?
答案 0 :(得分:0)
在Ruby On Rails中,你可以尝试下面的行显示HTML
type Msg
= DragStart Position
| DragAt Position
| DragEnd Position
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
( updateHelp msg model, Cmd.none )
updateHelp : Msg -> Model -> Model
updateHelp msg ({position, drag} as model) =
case msg of
DragStart xy ->
Model position (Just (Drag xy xy))
DragAt xy ->
Model position (Maybe.map (\{start} -> Drag start xy) drag)
DragEnd _ ->
Model (getPosition model) Nothing
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
case model.drag of
Nothing ->
Sub.none
Just _ ->
Sub.batch [ Mouse.moves DragAt, Mouse.ups DragEnd ]
它将输出如下:"在我们国家的首都,杀人事件增加了50%。"