Skip to content

Instantly share code, notes, and snippets.

@g0t4
Created December 12, 2012 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g0t4/4271829 to your computer and use it in GitHub Desktop.
Save g0t4/4271829 to your computer and use it in GitHub Desktop.
Why manually replace crap over and over, why not write code to do it if it saves time :)
[Test]
public void METHOD_SCENARIO_EXPECTATION()
{
var path = @"..\..\..\View.spark";
var code = File.ReadAllLines(path);
for (int lineNumber = 0; lineNumber < code.Length; lineNumber++)
{
var line = code[lineNumber];
var classControlLabel = "class=\"control-label\"";
if(line.Contains(classControlLabel))
{
if(code[lineNumber + 1].Contains("Attr(\"required") || code[lineNumber + 2].Contains("Attr(\"required"))
{
code[lineNumber] = code[lineNumber].Replace(classControlLabel, "class=\"control-label required\"");
}
}
}
File.WriteAllLines(path, code);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment