void ErbParser::parse(const QString &erb) { srcCode.clear(); srcCode.reserve(erb.length() * 2); erbData = erb; pos = 0; while (pos < erbData.length()) { int i = erbData.indexOf("<%", pos); QString text = erbData.mid(pos, i - pos); if (!text.isEmpty()) { // HTML output srcCode += QLatin1String(" responsebody += tr(\""); srcCode += ErbConverter::escapeNewline(text); srcCode += QLatin1String("\");\n"); } if (i >= 0) { pos = i; parsePercentTag(); } else { break; } } }
void ErbParser::parse(const QString &erb) { srcCode.clear(); srcCode.reserve(erb.length() * 2); // trimming strongly if (trimMode == StrongTrim) { erbData.clear(); for (auto &line : erb.split('\n', QString::SkipEmptyParts)) { QString trm = THtmlParser::trim(line); if (!trm.isEmpty()) { erbData += trm; erbData += '\n'; } } erbData = THtmlParser::trim(erbData); } else { erbData = erb; } pos = 0; while (pos < erbData.length()) { int i = erbData.indexOf("<%", pos); QString text = erbData.mid(pos, i - pos); if (!text.isEmpty()) { // HTML output if (isAsciiString(text)) { srcCode += QLatin1String(" responsebody += QLatin1String(\""); } else { srcCode += QLatin1String(" responsebody += tr(\""); } srcCode += ErbConverter::escapeNewline(text); srcCode += QLatin1String("\");\n"); } if (i >= 0) { pos = i; parsePercentTag(); } else { break; } } }