Created
February 15, 2021 01:31
-
-
Save doyle-flutter/8d1f95d8c52ae55cbe20db7f940b3f5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Future<void> doRender({required HttpRequest req, required HttpResponse res, required String path, Map<String, String>? data}) async { | |
final File _file = File(path); | |
final String _readData = await _file.readAsString(); | |
String _result = _readData; | |
if (data != null) { | |
data.keys.toList().forEach((String key) { | |
_result = _result.replaceAll("<do>$key</do>", data[key].toString()); | |
_result = _result.replaceAll("<do> $key </do>", data[key].toString()); | |
}); | |
} | |
res.headers.contentType = ContentType.html; | |
res.write(_result); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment