package com.brilliance.isc.doc.convert;

import com.brilliance.mda.runtime.mda.util.MdaUtils;
import freemarker.template.SimpleScalar;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;

import java.util.List;

public class FormatIsoHelper implements TemplateMethodModelEx {

    @Override
    public Object exec(List list) throws TemplateModelException {
        String value = ((SimpleScalar)list.get(0)).getAsString();
        if(MdaUtils.isEmpty(value)){
            value = " ";
        }
        value = value.replaceAll("\r?\n","<br/>");
        return value;
    }
}
